« first day (2761 days earlier)      last day (2412 days later) » 
00:00 - 14:0014:00 - 00:00

00:20
Cbg guys, I'm trying to find a project I came across before and was wondering if any of you had heard of it. Basically I came across a django project that was like an open source mimicry of Instagram. How should I go looking for this since I lack memory of the name of the package.
google "django instagram clone" for starters
and rhubarb
Can an RO kindly add this Q/A to the list of canonical questions on pandas loc based indexing?
I totally forgot it exists, but I want to remember from now, because it's the best dupe target I never remembered to find
 
2 hours later…
 
1 hour later…
03:20
hello
any one using scikit learn here
?
03:31
Hi
04:06
1
Q: Getting Rid of Lines in OpenCV-Python

Aayush Gadia Like I converted my original input to HSV color space image & applied the INRANGE function and found the green & blue lines & now i want to get rid of them and I want the image to look like in output....how shall i now get rid of the lines & replace them by the background color?? Code Snip...

Kindly help me
 
2 hours later…
06:22
cbg
can someone answer this : stackoverflow.com/questions/15856290/… ?
cbg
07:21
> Don't ask for answers to your recent Stack Overflow questions. Those who can answer are already watching the queue on the main site.
> If your question is eligible for a bounty (>= 48 hours old) and hasn't received a useful response, then you may link to it.
07:34
Is there a good answer on how to make a python package executable, like in python -m my_package arg
also, cbg
08:22
@Arne this is the best I could find
jpp
jpp
08:38
cbg
I answered a question yesterday about calculating tan of a variable in radians..
If your package is mainly intended to be executed (ie you're writing a command-line tool) you might want to consider using the console_scripts entry point to create a command people can run directly, without python -m ...
jpp
jpp
but it's disappeared, can't find it anywhere. it was on the brink (4x close votes), so I'm interested if it's lost forever.
@jpp nothing's lost forever on SO stackoverflow.com/questions/50223025/…
jpp
jpp
@Aran-Fey, thanks, how did you find this?
We discussed the question here yesterday
jpp
jpp
08:42
@Aran-Fey, OK, cool. Yeh I don't mind it getting deleted. I might write up my own Q&A (with a better question, obviously!).
Unless you guys have any objections?
I have my doubts about the usefulness of such a question, but I don't have objections
jpp
jpp
The question will change, don't worry. I'll probably word it as how to do the -1/+1 part of the series expansion, which may be non-trivial for non-Python guys.
the rest is fairly straightforward
@Aran-Fey That actually solved my problem, given that I was trying to make it work by having a my_package.py file in the root dir and getting all kinds of import errors.
You made a file with the same name as the package? Yeah, that wouldn't end well :p
It makes the python -m part work, and it's how pytest does it. Which I thought might be a good starting point
08:49
p = subprocess.Popen(['ps', '-ef', ], stdout=subprocess.PIPE)
out, err = p.communicate()
for line in out.splitlines():
  if killpattern in line:
    #print line.split(" ")
    pid = int(line.split(" ")[4]) #this fails sometimes ValueError: invalid literal for int() with base 10
I simply want to kill this pid
So why not print the segment that fails to see what it actually contains?
Try pid = int(line.split()[1]). Splitting on every single space looks like a really bad idea
@Arne The pytest package is named _pytest though, so there's no name clash. Not sure why they do it like that. Looks ugly to me.
TBH, I'd say parsing the ps output is a bad idea in general...
Why not look at something like psutil to get the process list and find the pid?
@Aran-Fey Ah, I missed that. Makes me wonder why they'd not use __main__.py instead
@ThiefMaster It's a library, this part only launches a test.
Hello. Anyone know how can I do unit testing and working with dates?
What's the common practice?
08:58
What's your case? Unless datetime.now() etc are involved just pick whatever date you want
if you do have code that gets the current time, use freezegun to set it to something static
Yes. datetime.now() is involved.
freezegun seems interesrting
@Aran-Fey Considering those retags, I always assumed you'd need a gold badge to do it, since they get posted here. But you have one, and still post them.
The thing is, the gold hammer doesn't work if you manually edit in the relevant tag (to prevent abuse). But you don't need a gold badge to edit the tags, you just need editing privileges
So yeah, retag-pls requests usually (always?) come from gold badgers
I see, sounds reasonable
09:15
Someone finally added a python tag, but my hammer didn't work. What the heck?
I don't think the hammer works with retagging.
Oh, I bet I know what happened. There was a suggested edit that I rejected, and afterwards someone "improved" that edit and added a python tag, so now I "participated in editing the question's tags" :/
"No longer needed" chat comments don't just go to mods right? They can go to anyone 20k+ with the privilege?
I'm making a bug report
I mean, if there are a bunch of comments that need flagging, do I request mod intervention instead of individually flagging each comment
09:22
@AshishNitinPatil just mods. But there are no "no longer needed" chat flags
Oops, I don't know why I included "chat" in that whole thing.
Comments on the main site is what I meant
09:38
@Aran-Fey Works thanks ;)
@jpp don't make a Q&A about a non-programming question:P And you can search your own deleted posts since you're >10k chat.stackoverflow.com/transcript/6?m=42294440#42294440
For <10k there's a "show recently deleted posts" tickbox in the profile
That sign change could just be the (-1)**k just like the math definition. I.e. "trivial"
ahha cabbage @jpp
jpp
jpp
@AndrasDeak, I know. I added that explanation too, still needs enumerate I think.
actually there's a way to remove enumerate :) ill add that
Enumerate is also "trivial" :D Dozen dupes for "loop with index"
This is mostly a heads-up that people are picky with self-answered Q&As
jpp
jpp
that's fine. if you go that far, there should never be any questions on SO !
I mean that seriously. 90% of questions, I claim, can be answered as a combination of up to 3 others.
That doesn't mean 90% of questions should be closed (or should they?).
09:51
It does.
@jpp re: meta, keep up the good work ;)
90% of new questions, easily
@jpp depends on the tag. If you'd follow , then closing only 90 % questions would be lax :D
(Which also explains it if you see me complaining about the stuff you answer :P)
the question is: "why is it that they need a combination of 3 questions" - if they've got 3 distinct problems, then that'd be too broad
if it is a single problem, with novel approach of combining 3 then that's not a duplicate
09:55
I'm not even sure about that
jpp
jpp
@AnttiHaapala, It's tough. Sometimes (in fact, always) the questioner can't break down the problem. Should they be punished for this?
Helping someone break down a problem is (IMHO) entirely the point of SO.
@jpp you haven't seen the C questions...
"Sort my numbers, find the second smallest and take its square root" may be unique but come on
the C questions are: "why my code crashes" -> then the answer is given, then they follow up with "I changed my code and it still crashes"
jpp
jpp
@AndrasDeak, You're right there are the obvious ones, but they are more like give me the codez..
I'm talking about ones where there's a genuine attempt.
09:56
@jpp closure is not punishment. Dupe closure especially isn't!
@AndrasDeak indeed.
I closed a C question as a duplicate yesterday, of 2 questions, and upvoted it.
commenting that it was a thousandth duplicate but upvoted it because it was well indented and written and contained a code proving that other aspects weren't broken.
jpp
jpp
Here's a good survey; what are your UV / DV ratios. I'll share mine: 2.7 UV : 1 DV.
However, I VTC a large number of questions (even if don't DV).
3,487 upvotes, 3,297 downvotes
that is surprisingly even
jpp
jpp
Yeh, I've taken a turn over the past month. I very rarely DV now.
3,813 Votes cast: delete :D
10:00
5.9k | 2.1k
@jpp you should dv more, not less
55 undelete
@jpp indeed, many of my downvotes are counter downvotes like "I could ignore this but since it is got an upvote, I don't want it to show up as "useful" because it isn't
jpp
jpp
Seeing all the feedback from "new users" is depressing.. Basically I VTC a lot, comment less on poor questions (just UV an existing comment).
So much garbage
jpp
jpp
Yup, we all agree on this. The question is how we react. Some questions (like the original trig one) are better closed sooner. Someone who cares might answer; if they really cared, write their own Q&A when it gets deleted. But that's their prerogative.
10:02
dupe hammer is a good thing
jpp
jpp
DV just alienates ppl. The other day someone edited their question with "PLEASE REMOVE THE -1 FROM MY QUESTION"
in c there are way too many duplicates. less so in python.
jpp
jpp
and guess what.. that edit pushed the question to ReOpen quee.
*queue. Problem exacerbated.
@jpp the thing is, should some people be alienated
jpp
jpp
I guess it's how optimistic you are.. I believe they can be good contributors (with a bit of direction).
Help vampires are a subset Q&A can't help.
10:04
Perhaps I am too harsh, I am comparing them with myself at 9 years of age.
The thing is, if the question lacks [mcve], and you point that out, and they start arguing about it, then at that point it is dv, cv move on, alienate.
@jpp DV is an integral part of SO though. I see how it takes getting used to if you weren't part of a forum where DVs are a thing, but I think they are valuable.
@jpp also, peer pressure badge is a thing :D
Else it is real hard to navigate between hard questions and bad questions
@jpp the solution to that is not to not downvote crap
jpp
jpp
@Arne, If a question has < -3, it's already off the front page. What advantage is it to have it at -10 ?
10:07
@jpp I'd say none
@jpp nothing at that point, except... idk how question-ban works :D
jpp
jpp
The navigation part is already achieved; I frequently see -5 or -10 questions which don't need to be pushed that far.
it might take the score into account
1142 up, 3144 down
And don't get me started on pity upvotes
jpp
jpp
@AndrasDeak, looks like you're an outlier here :)
10:09
@jpp he started later than me :P
he didn't see the good Q/A :D
I probably am, but most of the others have been users far longer. Much less crap back then
Anyway, rhubarb for now
rbrb
I am not an elitist when it comes to who can ask a question, but, I've asked only 9 questions on Stack Overflow
I ran the UV/DV ratio query today, and the amount of downvotes truly seems to be ever rising. Just like the past few years. data.stackexchange.com/stackoverflow/query/219032/…
what's that 2015 change
@Arne there's a problem though -
you're not counting deleted questions
10:14
Ah, that's why there is the spike on the last month
good to know
or wait.. I might have misunderstood your comment
no, you've understood it :D
many of those will be roombaed, deleted
but even then the trend is there: upvotes decreasing, downvotes increasing
jpp
jpp
what happened earlier 2015, is this a cyclical thing?
much like economies, we go through phases of disgust & leniency?
@jpp I don't remember anything significant
jpp
jpp
10:19
I think the real point is 8 years ago simple programming wasn't taught actively across 1st world educational curriculums. Programming was a specialized skill in many companies. Nowadays Python is used in the same line as Excel / VBA.
I think I know what it is:
it is the HIV queue
jpp
jpp
So now we're left with a huge base of people programming who aren't professionals or enthusiasts.
and Triassic queue
at the end of the review it says: "ok then upvote the post"
also, close votes were changed
jjj
jjj
cabbage all
jjj
jjj
10:24
I'm trying to build a list of tuples recursively traversing a tree. I believe Im close but something is off. Could someone have a look pls
In [103]: def traverse_tree(tree, indent = 0):
     ...:     edges = []
     ...:
     ...:     for subtree in tree:
     ...:         print('  '*indent, 'edges:', edges)
     ...:         print('  '*indent, 'tree', subtree, '\n')
     ...:         if isinstance(subtree, nltk.tree.Tree):
     ...:             if subtree.label() == 'Pred' or subtree.label() == 'Var':
     ...:                 edges.append((subtree.leaves()[0], traverse_tree(subtree, indent + 1)))
     ...:             else:
     ...:                 edges.append(traverse_tree(subtree, indent + 1))
so what is it that is off
jjj
jjj
My tree Tree('S', [Tree('Predi', [Tree('Pred', ['R']), Tree('Args', [Tree('Predi', [Tree('Pred', ['R']), Tree('Args', [Tree('Var', ['p']), Tree('Var', ['p'])])]), Tree('Var', ['p'])])])])
jjj
jjj
welll, the result is: [[('R', []), [[('R', []), [('p', []), ('p', [])]], ('p', [])]]]
and... ?
that's what your code does. What should it do?
jjj
jjj
10:27
And I'd like it to be: [('R', 'R'), ('R', 'p'), ('R', 'p'), ('R','p')]
Sorry Im terribly slow at typing
so, first things first, append will append a list as an element
change that second one to extend and it would be different
jjj
jjj
I tried that. then the whole recursion kinda misses the structure
or, pass in the list, then just append the values there, not trying to return anything
jjj
jjj
oh, thanks haven't thought of that
ah so now I even get what you're doing
so let me ask this again:
hmhm
@Arne [sudo] password for arne:
@jjj I still don't know exactly how you get these :D
jjj
jjj
10:32
Which ones you mean?
but if it is about the parent/child, then pass the parent type as an argument to the recursive invocation
Any perf tips for this almost obscure function?
from functools import reduce
import operator


MOD = 10**9 + 7


def nthDerivative(coefficients, n, x):
    return sum(coefficients[i]*reduce(operator.mul, range(i, i-n, -1), 1)*pow(x, i-n, MOD) for i in range(n, len(coefficients))) % MOD
@AnttiHaapala Quite glad i didn't miss-tab while typing something a bit more critical :D
jjj
jjj
@AnttiHaapala ok, Ill try that
10:34
@AshishNitinPatil though it is using it there alread I see
ah but mod inside
reduce by mod within the multiplication, within the sum, everywhere
cool, will try that
idk how big the numbers are
but yeah, bignum math is slooow
and your MOD fits in 32 bits
def nthDerivative(coefficients, n, x):
    return sum(((coefficients[i] % MOD)*(reduce(operator.mul, range(i, i-n, -1), 1) % MOD)*pow(x, i-n, MOD)) % MOD for i in range(n, len(coefficients))) % MOD
no use, anyway, giving up, since I did solve the problem, but this is ridiculously obscure now
I can probably write the same thing in C and it'd pass
10:38
it is still no mod for the numbers inside the reduce
what are the inputs
what is i, i - n?
also for loop would probably be faster :D
hmm
@AnttiHaapala than the sum over the generator?
@AshishNitinPatil table the !
ah but it wouldn't help here now would it
It's okay, I can check back other people's Python solution in like ~8 hours. Will report back (if not stupid enough)
in any case
the most stupid thing to do is to try to make it into a oneliner :P
Trust me, I had like 3 beautiful functions.
It was so readable that you probably didn't need to know the question
10:49
Yeah those are the worst
I don't like that poly representation
does python's garbage colector do something?
@Neoares It does a lot of things, mainly collecting garbage :-p (sorry, but you could definitely frame your question a little more better)
umm, why would it exist if it didn't do anything?
@AshishNitinPatil I just deleted some variables, but memory usage remains the same
with del var
@Neoares I don't think it's that easy, see stackoverflow.com/questions/1316767/…
But yes, it should essentially do the job.
10:59
If there's a reference cycle, you have to wait for the garbage collector to start its next collection cycle. Or you can start it manually with gc.collect()
wow, gc.collect freed 6GB of memory :)
there's reference counting + GC for cycles in cpython
Former is usually near instantaneous
Maybe unless you are in ipython?
no, it's just ipython holds other references
But I tried del'ling large things in it and I think it god freed. Unsure though
anyway, if you are using ipython, you shouldn't be too worried about memory in the first place I suppose
11:05
How so?
I meant, ipython shell
You could always restart it if memory is becoming an issue.
Unless working with large files
But then ipython isn't your issue, probably your code is
Hi Guys. I Hope your fine. I need an approach, how can I map namedtuples items in a list, if the item occurs several times.`# speaker = namedtuple('Speaker', 'speaker goroup text')`
``
`for info in redner:`
` x = speaker(info[0], info[2], sent)`
`speakerlist.append(x)` How can I now make something like, if info[0] occurs several time in the speakerlist, then map the speaker.sent. Thank you very much!
        # speaker = namedtuple('Speaker', 'speaker goroup text')

        for info in redner:
            x = speaker(info[0], info[2], sent)
            speakerlist.append(x)
@AshishNitinPatil thank you
How can I now make something like, if info[0] occurs several time in the speakerlist, then map the speaker.text. Thank you very much!
Your ask is still unclear to me, perhaps an example would help clarify more.
11:13
@AshishNitinPatil that's Neoares' case
@AshishNitinPatil I'm working with huge files
good luck :-p
I'm reducing my dataframe size, since pandas reads everything as float64, int64, etc
now I have this
dtypes: datetime64[ns](1), float32(2), object(2), uint16(2), uint32(1), uint8(7)
Name1, GroupX, TextX
Name2, GroupX, TextX
Name3, GroupX, TextX
Name2, GroupX, TextX

Name2, GroupX, TextX; TextX
If a Name comes several time, then summary the texts of this Name like this
@AshishNitinPatil
Use a dict that maps info[0] to speaker objects:
speakers = {}

for info in redner:
    if info[0] in speakers:
        speakers[info[0]].text += sent
    else:
        x = speaker(info[0], info[2], sent)
        speakerlist.append(x)
        speakers[info[0]] = x
11:28
   speakers[info[0]].text += sent
AttributeError: can't set attribute
@Aran-Fey I got this error
bleh, namedtuples
Stop using namedtuples
Have you an other approach for this problem? :)
@Neoares if you have a 10GB csv then doubles and longs are not your primary concern, probably
for the heck of it loop over with a csv reader, gather the numeric data into arrays and see how large that gets
@madik_atma is this different from your question on main? stackoverflow.com/questions/50224463/…
jpp
jpp
Really, the best option for storing large numeric arrays is HDF5. You have the option to work in or out of memory.
@jpp the problem is strings
jpp
jpp
11:34
You can optimize those too (lzf, gzip compression in hdf5)
@AndrasDeak no its the same problem.. unfortunately my English is not so good and maybe I cannot explain the problem clearly..
jpp
jpp
if you have repeated strings, read them in as categories, you could save a huge amount of memory
@madik_atma Yes, but it's ugly. You can store the index of the speaker in the dict, and replace the previous speaker instance with a new one:
speakers = {}

for info in redner:
    if info[0] in speakers:
        i = speakers[info[0]]
        x = speaker(info[0], info[2], speakerlist[i].text + sent)
        speakerlist[i] = x
    else:
        x = speaker(info[0], info[2], sent)
        speakers[info[0]] = len(speakerlist)
        speakerlist.append(x)
@madik_atma the problem is that we prefer that users don't ask their questions on two parallel channels, this leads to information fragmentation and a waste of efforts. Also we prefer not to ask for help here with new questions as per the room rules. If you don't get an answer in 2 days, you're welcome to ask for help here
@AndrasDeak then what's the problem? to have a big csv file is not a problem, except you mean I should split it
(it's already split in 5 parts)
also, I'm processing the data and storing it with pickle
so it went down from 10 to 3.5GB
11:40
ah, OK, I didn't know you want to push it further down
and yes, I know "objects" is what takes more space
I was still at "can't read because it needs 26+ GB" :P
noooo :)
actually I think now I can fit both dataframes
cause I actually have 2, 10GB each
and the nice thing is that the biggest "object" of both of them is a hash string that will be used to join both dataframes, and then I will be able to delete the column
@AndrasDeak thank you for your information
@Aran-Fey thank you for your suggestion. this approach will help me
12:28
'morning cabbage all
12:54
morning cbg
cbg
what's the best way to check if any of 4 variables is 0?
I was thinking of a*b*c*d == 0
I'd be inclined to do 0 in (a,b,c,d)
I like it
or perhaps a list or set literal instead of a tuple. It would be good to benchmark all of them and see which one does setup + membership testing the fastest
I'd say a tuple is faster
or at least not slower?
13:07
Not that I expect the difference to be huge anyway, when there are only four elements
IMO "best" would be what Kevin suggested in the first go. Performance shouldn't be an issue (or even considered) when it's just 4 numbers.
well, it's done a massive number of times, anyway
What application?
bool(a + b + c + d)
?
And how much is "massive"?
@noumenal he wants "any" of the 4 to be 0 to give True
and bool won't do since he said 0 specifically
13:16
\o meteor-landed-and-knocked-my-dinos-out-cbg
@AshishNitinPatil a could still be an array in a * b * c * d, so if you think type checking is a problem, that solution has the same problem.
You could just do:

bool(a + b + c + d) + 0
I think what Kevin put would be the more efficient, intuitive way of doing it
@noumenal Doesn't look right to me.
>>> a = 1
>>> b = 2
>>> c = 3
>>> d = 4
>>> #none of these values are zero; therefore, the result should be False.
>>> bool(a + b + c + d) + 0
1
1 is not False, so this is a problem
DSM
DSM
all(cabbage(friend) for friend in rooms[6])
8
Anyone who was interested in that stupid perf issue I was having, turns out I wasn't optimizing (modulus) where it was actually necessary.
13:22
What about any(a, b, c, d)?
Do you mean any([a,b,c,d])? For the values I assigned in my above example, it gives True. It's supposed to be False.
DSM
DSM
not all, I guess, but this seems very silly.
not any((a,b,c,d)) versus 0 in (a, b, c, d) hmm...
DSM
DSM
I don't think not any will do what you want.
13:26
not any((a,b,c,d)) doesn't work either because it gives False for a=0,b=1,c=2,d=3, when it should be True
jpp
jpp
Do we take [mcve] too far? 3 DV & 3 Close votes for this one: stackoverflow.com/questions/50234355/…
not all is the one that gives the right logic. Assuming we're fine with detecting falsey values and not just 0.
Right, it only checks if any is not 0
However, 0 is false
Kind of. 0 equals False, but 0 does not have the same identity as False.
>>> 0 == False
True
>>> 0 is False
False
They may have been identical back in the day. A little before my time though, so I'm not sure.
@jpp Yes, "no mcve" is a horribly unsuitable close reason for that "gimme teh codez" question. I don't think it needs to be closed, though I do admit that it could be considered both unclear and broad
13:34
Hmmm.... not (a | b | c | d) ?
@jpp You can do away with the itertools.count if you use a list iterator instead:
def foo(func, lst, nested_list):
    itr = iter(lst)
    res = [[operation(j, next(itr)) for j in i] for i in nested_list]
    return res
@noumenal Gives False for a=0,b=1,c=2,d=3, but it should give True
If your logic is correct, then not (a & b & c & d)
jpp
jpp
@Aran-Fey, Yeh I updated my answer ~10 mins ago
TIL I'm blind
13:37
@noumenal That should work, provided all of the values are positive integers.
bitwise and gets a bit funky when negatives are involved
>>> not(-20 & 2 & 2 & 2)
True
Or, no, it doesn't work even for positive ints.
>>> not(1 & 1 & 1 & 2)
True
not(a and b and c and d) would work, but then you're just writing out the logic of not all the long way
It's not clever, but is it good?
As in, is it faster than doing if 0 in (a,b,c,d)? You'd have to test it to be sure
"not clever" is one thing, "confusing" is another
DSM
DSM
Given how long we've spent talking about this, saving time is clearly not a high priority. ;-)
13:50
question is whose time, I guess :P
Thought I might pick up my js project again today, even though I got discouraged when I asked the js chat room if I could override arithmetic operators and they told me "you don't want to do that." So I went in and asked if I could embed a javascript function in a DOM node, and they told me "you don't want to do that". I'm surprised how frequently I find myself doing things I don't want to do.
did that make you feel unwelcome?
I'm pretty sure you're joking, but honestly it did.
:(
they're getting pretty serious about that nowadays, so you could try again, and tell them when you feel that way
I may give it another shot the next time I've got some free project time.
13:54
they even have a github where soft-skill issues can be raised
@Kevin I try to preface things with "Yeah, I realize this may be crazy - I'm not trying to write production code here..."
I mean, there's a charitable reading of both of those replies, the first one being "operator overloading hasn't been integrated into the language and it's a contentious issue whether it should be and you should think carefully about whether it's really something you need" and the second one being "not natively; you could embed a string that looks like js and eval() it when you need to, but we all know the reasons not to use eval()"
00:00 - 14:0014:00 - 00:00

« first day (2761 days earlier)      last day (2412 days later) »