« first day (3141 days earlier)      last day (1817 days later) » 
01:00 - 15:0015:00 - 00:00

3:08 PM
@DeveshKumarSingh Interesting! I have no idea why that recurses.
 
I thought the self reference self.methods = [self.method] causes it to bottom out, since changing it to self.methods = [A.method] or self.methods = [self.method()] resolves the recursion overflow
 
first.methods[0] == second.methods[0]
also causes the recursion.
 
I think I got the reason
In this question, a comment by Aran-Fey
0
Q: Maximum recursion error in `__eq__` implementation

code_conundrumclass Coordinate(object): def __init__(self,x,y): self.x = x self.y = y def getX(self): # Getter method for a Coordinate object's x coordinate. # Getter methods are better practice than just accessing an attribute directly return self.x def ge...

```
self.getX == other.getX compares two bound methods. Bound methods are considered equal if the method is the same, and the instances they're bound to are equal. So comparing two bound methods also compares the instances, which calls the eq method again, which compares bound methods again, etc.
 
@DeveshKumarSingh - That's it
 
@DeveshKumarSingh Well done!
So put that info in your answer.
 
3:20 PM
dir(self) == dir(other)
 
yes, I did put :) I never saw anyone comparing bound methods by equality, so never thought of this behaviour
 
works but not clear if that satisfies the OPs desire
 
I have done comparison of bound methods in the past to detect if a method has been overridden, but always used 'is' for this.
 
BTW is this behaviour documented in a PEP ?
 
if instance.some_method is BaseClass.some_method:
    print('not overridden')
 
3:26 PM
cbg
 
@PaulMcG much safer :)
and I couldn't find any document which mentions the above behavior, can someone point me to one please :)
 
cbg
 
3:44 PM
I'm having trouble parsing a file of sql statements. It's essentially just a very very long line of (a, b, c),(d, e, f), ..., (x, y, z);, but quoting rules make it a bit annoying, and I don't know how to treat it as exotic csv where newline="),("
is there a shortcut that I'm not aware of, or do I need to write a custom parser for this?
 
Hmm, I thought github.com/python/cpython/blob/master/Objects/… is where bound method equality checking is implemented, but I don't see how it can recurse.
Maybe this is for unbound methods and bound methods are implemented elsewhere
Ah, bound method equality checking is probably at github.com/python/cpython/blob/…
 
I am not very literal in C, but which line does the recursive call here github.com/python/cpython/blob/… :)
 
eq = PyObject_RichCompareBool(a->func, b->func, Py_EQ); might be able to recurse, but I haven't delved too deep there
If func is a methodobject, and if it just calls methodobject.c/meth_richcompare, then I don't see how it could compare self objects at any point.
 
aah okay, so this is something within the source code, but I was wondering if it was publically documented somewhere
 
4:00 PM
Surely it must compare self, or else "bouba".index == "kiki".index would evaluate to True. So my mental model must be incorrect.
@DeveshKumarSingh I was also hoping it would be documented somewhere. I went into the source in the faint hope that I'd find a comment saying //compare self instances, in accordance with PEP <some number>. No luck so far.
The flippant conclusion is "whatever CPython does is the public standard" but that's really unsatisfying
 
user7437554
Is there any simple way to plot many columns of a csv file in one plot?
 
user7437554
like A vs B,C,D,E
 
user7437554
I'm trying with pandas, but not sure if is possible
 
I think the equality check eventually gets delegated to github.com/python/cpython/blob/…, which checks that the unbound methods are equal, and that the self objects are referentially identical. But this doesn't seem to jive with the observed behavior that the self objects only need to be equal.
I am confused, because my own tests seem to indicate that self equality is not sufficient for bound methods to compare equal:
>>> x = "A"*10000
>>> y = "A"*10000
>>> x is y
False
>>> x == y
True
>>> x.index == y.index
False
Maybe built-in methods and bound methods play by different rules.
 
4:27 PM
undercover red panda ^
 
You don't get stuff like this on SO: physics.stackexchange.com/questions/481404/…
 
scientific interpretation of the bible?
 
@PM2Ring WTYam! ʘʘ
 
4:43 PM
When I retire, I plan to spend my time writing the next great Timecube-esque manifesto. The mandelbrot set will probably show up a lot.
 
4:55 PM
There's an Indian American computer scientist who claims to have discovered a whole bunch of astronomical data encoded in ancient scriptures, primarily the Rig Veda. One of his fans has been rather prolific lately on Astronomy.SE. en.wikipedia.org/wiki/Subhash_Kak
 
5:08 PM
Two mathematicians walk into a bar. The first orders a double shot of whiskey. The second says "I'll have 10 times what he got." referring to the first mathematician. The bar tender responds "Now that's an order of magnitude."
 
user7437554
please help :(
 
user7437554
time_step=data['Time step (secs)']
time=[]
tcounter=0
for i in time_step:
    tcounter+=i
    time.append(round(tcounter,3))
print(time)

counter=2
for i in range(len(data.columns)-3):
    #column=data.columns[counter]
    #print(column)
    plotted_data=data.plot.scatter(x=time, y=data.columns[counter])
    fig = plotted_data.get_figure()
    fig.savefig('{}.png'.format(data.columns[counter]))
    counter+=1
 
user7437554
I can't make it work :@
 
5:12 PM
I wonder whether you could replace that first loop with np.cumsum
 
user7437554
uhmm
 
Using df.plot and passing explicit x and y is a bit pointless. Why not matplotlib.pyplot.plot then?
Also "I can't make it work"?
May 14 at 13:17, by Andras Deak
"The output is weird", "it doesn't work", "there is an error" is never sufficient information. How is the output weird? When it doesn't work, is there an error? Does it produce nothing or something wrong instead? What is the error message? What is the expected output? Put together a minimal example if necessary. That makes it easier for others to help you.
 
user7437554
@AndrasDeak thanks. Yes that's helpful. But I've started doin something else and then forgot about matplotlib
 
user7437554
although I'm not sure how to modify it for matplotlib
 
user7437554
just plt.plot ?
 
user7437554
5:20 PM
the error is
 
user7437554
KeyError: u"None of [Float64Index([0.002, 0.003, 0.005, 0.007, 0.008, 0.009, 0.011, 0.012, 0.084, 0.086, 0.088, 0.089, 0.091],\n dtype='float64')] are in the [columns]"
 
Strange, that's not the error I get. I get NameError: name 'data' is not defined on line 1.
Go ahead and provide code that produces exactly the error you're getting and then we might be able to assist further.
 
user7437554
@Kevin that's fair. Ok
 
Reduce it to minimal as well
 
user7437554
I'm trying
 
user7437554
 
user7437554
I've taken both advices I think
 
File not found
 
user7437554
but I can't paste the file it's huge
 
6 mins ago, by Andras Deak
Reduce it to minimal as well
 
Please construct a file for us containing only a small amount of data, while still reproducing the problem
 
user7437554
5:31 PM
on my way
 
That means you have to work harder
@Kevin not even a file, really
 
Yeah, constructing the data inside the code itself would be ideal
 
df = pd.DataFrame(dict_of_columns)
 
user7437554
uhu I am not sure how to proceed
 
user7437554
If I do data=[paste the data]
 
user7437554
5:33 PM
It'd be wrong
 
Rhubarb
 
Going by df = pd.DataFrame(dict_of_columns), rather than a list it would need to be a dictionary whose keys are column names.
 
Indeed (among other options)
I think you can use lists for row-wise data? Not sure
 
As in a 2D list?
 
This is why I was (reluctantly) willing to accept minimal data in csv form -- so we don't have to go through the error-prone process of learning how to construct dataframes manually
 
5:37 PM
{'col_name': [val1, val2, ...], ...} is the way I always go with examples, but you can throw a 2D np array into a DF with no issues, it will name the columns for you
 
"But surely it is easier for the question-answerers to have a completely self-contained script?", you ask. Yes... if we don't also have to give a lecture about the proper structure of the data you pass to pd.DataFrame
 
@Kevin option C: reject until it executes
 
I occasionally fantasize about stonewalling querents with "that's not an MCVE. Give us an MCVE." and providing no additional detail. But I suspect that would end not with an MCVE but with the querent submitting incrementally more MCVE-like snippets until someone other than me decides "eh, good enough" and tries to solve the problem with the less-than-perfect information available to them
If I was a cold-hearted tyrant I might impose a strict MCVE requirement, and also kick anyone trying to answer a question that doesn't have an MCVE. I imagine this would make almost everyone angry almost immediately
 
Min-reprex or bust
 
There ought to be a "Hostage" privilege that allows bestowed users to lock a question until OP has met demands.
 
5:46 PM
I would like to do an A/B test to see if tyranny is a better chat room moderation system than what we've got now. Please join me in the Democratic Republic of Python room...
Or else! (tm)
 
@everyoneelse I can't tell if Kevin is serious and it worries me.
 
wim
my favourite pickle is b'\x80\x03X\x04\x00\x00\x00\xf0\x9f\xa5\x92q\x00.' . but b'V\\U0001f952\np0\n.' is pretty good too
 
Protip: never give Kevin any real power.
 
r/StoriesAboutKevin seems to only have stories that aren't about Kevin
 
^^ideone.com/phjP4O for those too scared/lazy to unpickle those strings on their own machine
 
5:52 PM
did you just pickle a pickle
 
wim
what?? how did that happen. I serialized a cucumber
 
@Kevin The recent xkcd A/B test comic was a bit of a fizzer. The forum thread only got 3 replies. m.xkcd.com/2151
 
I thought it was pretty clever, although I can see how it might not provoke much conversation
Compared to, I don't know, a physics joke that leads into 300 pages of brainstorming about how you could put an egg into orbit without breaking it
 
My favourite bit was the mouseover text.
 
user7437554
Well I don't know how to convert it to something useful
 
5:56 PM
If I were trying to construct a minimal data set, the first thing I'd try is to delete every line from the csv file except the first five or so
(disclaimer: make a backup first)
 
user7437554
fine, but then?
 
The thread for Westerns has evolved into a discussion of whether Lord of the Rings can be classed as a Western. Someone pointed out that Aragorn is a Ranger. Now I have visions of a westernized LotR, with Chuck Norris as Aragorn.
 
user7437554
I've tried to convert it to 2D array but not sure it'd be useful
 
@santimirandarp no
 
@santimirandarp Then I would run my code on the tiny CSV to see if it still produces the error. If it does, I would put the tiny CSV into a pastebin and share it with my peers.
 
5:59 PM
data.plot.scatter(x=time, y=data.columns[counter])
Look at that, and look at the error. Now look at your data again.
(The data is now a horse...)
 
user7437554
I've modified the code for matplotlib as you told me
 
OK.
 
user7437554
Same error, x and y different size
 
Indeed.
 
user7437554
uhmm the counter might be wrong
 
6:01 PM
Probably not.
 
user7437554
I've checked the lenght
 
Of what?
 
user7437554
of time (the x axis) and the columns
 
user7437554
both 54
 
x=time, y=data.columns[counter]
did you check time and data.columns[counter]?
it's written right there
 
user7437554
6:02 PM
When I checked I used data.columns['headername']
 
What is that and why?
 
user7437554
but I supposed it was the same
 
@PM2Ring Wow that was a lot of work. Now that I'm done reading explainxkcd.com/wiki/index.php/2151:_A/B I'm uncertain if I think it's funny
 
you never suppose
 
user7437554
it selects the column according to the name data.columns['headername']
 
6:03 PM
The reason you have a bug in the first place is that you supposed something that was false.
@santimirandarp is data.columns itself a dataframe? I doubt it.
 
(this probably won't solve your problem, but I want to point out that you almost never need to manually increment a variable by 1 when you have access to enumerate and two-argument range and slicing and all of Python's other fun list manipulating toys)
 
In fact I'd expect data.columns['headername'] to be an error
 
user7437554
Yes, thanks @Kevin but I need to solve those problems fast so I went to the simplest
 
user7437554
let me check again
 
Do you and me both a favour and check your actual data you're trying to plot.
 
6:05 PM
This is a brilliant piece of AI code that could start the singularity written in a scripting language that has yet to be developed:
a;lksdjfa;lksdjfa;lkjlk
;lkdjf;alksdjf
oiu349r8idofgnasdfj
I'm just waiting for a monkey to develop the language.
 
lol
 
user7437554
a=data.columns[1]

print(a)

output: Time step (secs)
 
@piRSquared that's not how evolution works
@santimirandarp ooooh, data.columns, as in the columns of the dataframe
So... you're plotting time (a list of numbers) vs an item from a list of strings.
And...they have different length.
Let me know if any of this is surprising.
 
user7437554
oh damn
 
user7437554
but why I got length 54
 
6:08 PM
Odds are you don't even have to loop, just use a single call to scatter.
 
user7437554
im too confused
 
@santimirandarp because you did something wrong
 
user7437554
its data[counter]
 
user7437554
?
 
data.columns["whatever"] should try indexing a list with as tring which should aways error
 
6:09 PM
This week I watched Nausicaä of the Valley of the Wind and while the bio-punk apocalyptic setting was interesting, I didn't buy the backstory that view spoiler for a 33 year old film. I don't think evolution works that way.
 
@santimirandarp I'm not sure what's the idiomatic way to select a column using its ordinal. But this is what you have to do.
data[data.columns[counter]] will probably work but there has to be a more elegant way. I just don't know pandas.
 
user7437554
there is something like iloc[row,column]
 
df.iloc[:, counter], yeah
 
user7437554
now it produces something horrible but it works perfectly
 
user7437554
thanks @AndrasDeak
 
6:15 PM
no problem, but please practice boiling down problems to minimal examples
you'd need a dataframe with two columns and three rows to show this error
 
Minimal, Complete, and Verifiable Examples are a necessity but actually seeing it in the wild is a luxury
 
Possibly view spoiler but there isn't a whole lot of textual support for that theory
But now that I look at the synopsis for the source material, that appears to be the intended interpretation.
Leave it to Hollywood* to leave out 80% of the plot in their action blockbuster adaptations
(*Hollywood not actually involved in this process at any point)
 
PSA: don't put something on your watch list. You'll never watch it
Thus is the sad fate of Nausicaa as far as I am concerned
 
Maybe you'll get around to it in the next 33 years.
 
6-8 weeks sounds like a more reasonable span of time :P
 
6:25 PM
When the biopunk apocalypse happens in real life, it will become compulsory viewing for all survivors
 
7:06 PM
hello
does anyone know if there's any advantage/disadv in using classes vs Table() directly in SQLAlchemy?
also, when I create new tables, how can I skip existing ones?
 
7:28 PM
If it took me 15 minutes to figure out that the fix for the bug I'd been trying to squash was to swap the order of 2 parent classes, does that mean my code is bad? It probably does, doesn't it?
 
@Biarys Apparently there is a checkfirst parameter you can specify when calling create. Setting it to True means the table will only be created if it doesn't exist yet.
 
@ke
@Kevin It is True, but still it gives me the error
 
@Biarys I don't understand this question at all
 
1 or 2?
 
What is the error you're getting?
 
7:32 PM
sqlalchemy.exc.InvalidRequestError: Table 'backtest' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns
on an existing Table object.
 
Sam
Any of you guys ran a Flask app using Gunicorn in Docker before? I'm having a really annoying problem that if I start the server using the terminal command gunicorn -b 0.0.0.0:8000 app the app runs fine, but as soon as I put it into a Docker image and run it, my connection just hangs when attempting to make curl requests
 
@Biarys Is this definitely SQLAlchemy and not flask-sqlalchemy?
 
it is SQLAchemy
 
Then I don't know, sorry. I had this issue with flask-sqlalchemy and you can clear the meta-data there but I don't know why this would persist with sqlalchemy itself
 
i have seen that answer
I dont think it will work as the tables do exist in the database, but I am trying to skip them
if they dont exist - create, if the exists - skip
 
7:38 PM
The best suggestion I can give is that you didn't commit the changes of your session
 
doesnt MetaData.create_all() commit them?
I see the tables in db
 
Have you since added columns to the db?
 
yes
 
So is the class in sync with the database in terms of the fields it has?
 
yes I havent changed anything
 
7:42 PM
That's a contradiction
 
I saw the tables created yesterday, and I freshly connected today
 
I get a {RepeatedCompositeContainer} by a google api call, how can I convert that one to a dictionary?
 
hello
Type? Library?
I'd start with the google api docs.
 
7:58 PM
Hi, google natural language classification api I'm using the python wrapper
 
@Biarys What is your IDE/development software?
 
@roganjosh I found the reason why that happened. I meta.reflect() the db
 
And what does {RepeatedCompositeContainer} really mean? Is that an str? A repr? A type?
 
@Biarys ah, glad it's sorted :)
 
because of that, tables names are stored in meta prior their creation, hence the error
 
8:01 PM
@MatthiasHerrmann Searching those docs for RepeatedCompositeContainer returns... 0 results
 
@roganjosh thank you for your help :)
somebody said they spent 15 mins on debugging, I just spent 2 hours lol
do you know by any chance why anyone would meta.reflect() ?
 
@Biarys I find the SQLAlchemy tracebacks really tough to debug
 
The returned type is <class 'google.cloud.language_v1.types.ClassifyTextResponse'> - I posted RepeatedCompositeContainer because Pycharm showed it next to the variable name in the debug window
I want to convert the categories into a dictionary
 
wim
@Aran-Fey there's a reason it's called OOPs
 
Hmm, the documentation isn't too great, but I think categories is a list of dicts like [{name: confidence}, {name: confidence}]?
Or rather {'name': name, 'confidence': confidence}, which would be even more ridiculous
 
user7437554
8:14 PM
Any idea why it does not plot the values ?
 
user7437554
import matplotlib.pyplot as plt

list1=[x**2 for x in range(10)]
list2=[x**2 for x in range(10)]
mean=5
deviation=1
fig = plt.figure()
ax=fig.add_subplot(111)
text='\n Avg= ' + str(mean) +  '\n St. Dev = ' + str(deviation)
ax.text(0,0, text,transform=ax.transAxes)
ax.plot(list1, list2)
plt.savefig('{}.png'.format('thefig'))
plt.show()
plt.clf()
 
plt.clf()...?
 
user7437554
that's because it's part of a loop
 
and you don't have to pass the two args as x= and y= to plot(), they are positional args
@santimirandarp and does the plt.show() call block?
 
@Aran-Fey Oh, I found something Google example
 
user7437554
8:16 PM
block?
 
@santimirandarp does execution halt while the figure window is open?
 
It doesn't plot even if you remove the weird plt.clf()
 
user7437554
No, it continues
 
There's no point in having both plt.show() and plt.clf(). If the former blocks you'll have to close the figure anyway to continue. If the former doesn't block you'll delete the figure instantly. Forget about plt.clf().
 
@MatthiasHerrmann Good, examples are usually the most useful thing when it comes to one of google's python APIs. They can't code python to save their lives
 
user7437554
8:18 PM
@AndrasDeak not sure if I understand you, but in a for loop, when clf isnt there the plots goes all into one figure
 
Well at the moment it doesn't plot anything
 
user7437554
Why?
 
user7437554
I can't understand what's wrong, even if clf and show are removed
 
... I thought that's what we're trying to work out?
 
user7437554
yes, thats it
 
8:19 PM
@roganjosh it plots for me
 
It really doesn't for me, so the plot thickens <cough>
 
@santimirandarp your environment (jupyter?) is set up such that plt.show() doesn't block, and figures appear instantly. This is equivalent to having plt.ion() enable interactive mode. Since plt.show() doesn't block, it's a no-op, and clf will clear the plot right after it.
you either have to make it blocking if you want to see one plot at a time, or put fig = plt.figure() inside the loop to have one figure for each iteration all at once
 
Though, it appears I have inline plotting in Spyder on my home laptop. What are you trying to plot with?
 
And you don't have a loop in your example. I'd expect your example to create a non-empty png.
(so it's unclear what "it doesn't plot" means)
 
user7437554
it's not unclear for me, but maybe it's because we have different outputs
 
8:23 PM
What is not unclear to you?!
 
user7437554
the values of the lists arent in the plot, there are no points
 
In the figure saved to the file?
 
user7437554
yes
 
@roganjosh ^
 
user7437554
8:24 PM
both on jupyter and as a script
 
user7437554
yes, same as him
 
@santimirandarp You should be posting this, not me btw
 
my png ^
 
user7437554
but I post the whole code :(
 
user7437554
ok so what's the problem
 
8:25 PM
@santimirandarp you said something about a loop
 
And Andras is asking for clarification on what you mean by "no plot"
 
user7437554
is your computer too far from south america? XD
 
Anyway, I have to go out. Like I said, that's inline plotting in Spyder so I wouldn't be too sure that other things aren't getting in the way of Matplotlib here somehow
 
I deleted my comment so I deleted my chat about comment (-: nothing to see here.
 
wim
8:46 PM
(removed)
 
user7437554
now it works, don't' know exactly why @AndrasDeak
 
okay
 
user7437554
thanks again, you're a a good teacher :) ...quite rigorous...
 
I don't think ".. but..." is appropriate. "... and..." seems more so.
 
thanks, I try
 
8:56 PM
Whoa, imghdr.what is a real stdlib thing?!
 imghdr.what(filename, h=None)
    Tests the image data contained in the file named by filename, and returns a string describing the image type. If optional h is provided, the filename is ignored and h is assumed to contain the byte stream to test.
That interface sounds like it was created by a drunk, not a python programmer
 
wim
it's on the "dead batteries" list python.org/dev/peps/pep-0594/#imghdr
you can tell it's old because the module was named before vowels were invented
 
hahaha
welp. Just learned about a whole chunk of the stdlib I'd never seen before and 5 minutes later I learn it's all due to be removed. Not sure how I feel about this
 
> This can be cooperate environments or class rooms where external code is not permitted without legal approval.
corporate environments, right?
 
probably
 
dead batteries sounds a little disrespectful to the people who developed them.... I'd suggest "housekeeping"
 
9:15 PM
idk, batteries implies that they give power. dead batteries implies that they once gave power.
house keeping implies I need someone to change the toilet paper and wash the towels I used to clean up my vomit
 
housekeeping also suggests you get rid of clutter :P
or maybe that's more like spring cleaning.
 
I choose my rock 'n roll hotel version
 
Have you ever thrown out any batteries during spring cleaning?
 
only the dead ones deak
 
 
2 hours later…
11:47 PM
cbg
 
01:00 - 15:0015:00 - 00:00

« first day (3141 days earlier)      last day (1817 days later) »