« first day (2979 days earlier)      last day (1972 days later) » 
00:00 - 22:0022:00 - 00:00

12:09 AM
   %D     Equivalent to %m/%d/%y.  (Yecch—for Americans only.  Americans should note that in other countries %d/%m/%y is rather common.  This means that in international context this format is ambiguous and should not be  used.)
found in man strftime ^ :D
 
wim
12:20 AM
Oh no, hats are back. This stuff is played out.
 
You can disable hats. I just mind the disruption
 
Hey guys - bit of a random question... if I hack something together on my off-hours in order to improve some aspect of my work (c++/python) (and build something cool) can I open source it?
 
12:36 AM
Probably depends on your job and contract
 
@wKavey 1. What country do you live in? 2. What does your employment contract say?
 
@wKavey unlikely, but whether the employer would ever know is how distantly removed from the project the code is
Beforehand I have been required to sign an NDA that was some blanket doc they took from some online source, and later been encouraged to strike up conversations with the owners to opensource libraries to try get features implemented. It's a serious grey area.
If the code gives the company no competitive advantage and you don't stand to make money from it, they may even support you if there is the possibility of someone else extending it might help them
But, almost certainly, it's flatly forbidden on paper as it stands
And, not only forbidden, forbidden in a way that's legally enforceable
 
 
5 hours later…
6:02 AM
cbg
 
6:15 AM
cbg
 
hey, my list in a function gets array elements somehow. I havent even imported numpy
0.0, 0.0, 0.0, 0.0, 0.0, 139153.0950620394, 0.0, 139153.0950620394, 0.0, 0.0, 0.0, 0.0]
1524
here
[348677416.01441944, 9832423.89076813, 1370826706.427002, 9832423.89076813, 90864460386.7043, 2681586405.4339113, 343021814152.744, 2681586405.4339113, 0.0, 0.0, 0.0, 0.0]
1528
here
[array([1.41825398e+11]), 5591137104.248508, array([-1.60926547e+11]), 5591137104.248508, array([6.67894066e+12]), 197166277649.86664, array([5.6139648e+12]), 197166277649.86664, 0.0, 0.0, 0.0, 0.0]
any clue why this is happening?
theres a loop that calls the function multiple times and feeds it new data
anyone here?
 
6:36 AM
cabbage
Did you calculate the 50 billion gens @wim?
 
6:57 AM
Cbg
I can't figure out the summation rule for today's AoC =(
It's neither the count of all plants, nor the sum of all pot indices that ever contained a plant
.. or i can't write code without bugs, which is also always an option
 
wim
7:14 AM
@Arne it is the sum of all pot indices that contain a plant
but only indices for the current generation, not over "all time" (which was a mistake I made initially by neglecting to read the problem statement carefully...)
 
Ah, reading comprehension, my nemesis.
Thx
 
wim
@ReblochonMasque it's too kind of Eric to use "50 billion". Better would be 500k or something which seems tempting enough to brute-force but actually would take 20 hours or whatever
 
Some had already submitted a correct answer while I was still trying to understand the task!
 
wim
7:51 AM
day 12 code ... no library imports! (apart from aocd of course)
 
8:39 AM
@wim nice solution, i like the part where view spoiler.
But it only works because ..... -> # is not a rule, which is a bold assumption :p
 
wim
9:23 AM
if ..... is a rule there can not be any solution
 
they didn't specify a maximum cave size, so I'd assume we get infinity plants after the first generation
 
9:44 AM
Hi cabbage
Can someone help me convert a loop in pandas inbuilt-function?
 
10:04 AM
Ok , suppose I have 3 coumns [ A,B,C ] and I want to take only those rows where B value is more than 100
How to do that in pandas?
 
 
1 hour later…
11:36 AM
cbg
@wim I did it the other way around with a max number of imports
it's much slower than yours but I got it right the first time
@MikhailTal you imported something that uses numpy arrays. You can't expect us to debug code we can't see, right?
 
 
1 hour later…
user6718998
12:50 PM
Hi guys. If anyone got some time, could you take a look at my algorithm? pastebin.com/hXWb8xjD I am trying to replicate a schrodinger equation by using thomas' algorithm, but I get warnings like:overflow encountered in cdouble_scalars and RuntimeWarning: invalid value encountered in cdouble_scalars and noticed at some point that my lists become lists of NaN... anyone could maybe point me where and why this happens ? for some values of N and h, it would even say 'inf' sometimes
 
alpha_list.append(1 / (C - alpha_list[-1]))
whatever that is, it might contain a division by zero
I know C is complex, but still
 
user6718998
in case N=1000, tau=0.001 and i initialize alpha
 
user6718998
[0[ and beta[0] with 1
 
sometimes inf, sometimes nan sounds like complex infinity
 
user6718998
i get 'inf'
 
12:58 PM
>>> 1/np.complex128(0.)
__main__:1: RuntimeWarning: divide by zero encountered in cdouble_scalars
__main__:1: RuntimeWarning: invalid value encountered in cdouble_scalars
(inf+nanj)
>>> 1j/np.complex128(0.)
(nan+infj)
 
user6718998
but it is impossible to divide by 0
 
that's why you get nan :P
 
user6718998
because I tested the algorithm in wolfram mathematica
 
OOOOH, I see. My bad. So python is buggy.
 
user6718998
between (N=100, tau 0.01) and (N=1000, tau=0.001) printed value should decrease 10.000 times
 
user6718998
1:00 PM
that's what I should get
 
user6718998
if I increase tau in both cases, by *10, then I will descend from 1000 to 1
 
user6718998
only
 
Maybe, just maybe, your code doesn't do what you think it does. In programming terms we call this "a bug". I'm surprised you haven't encountered this concept beore
 
user6718998
Yes ofc I am aware of it..
 
What we usually do in this scenario is the so-called "debugging" procedure.
It more or less means trying to find something in your code that does what you see instead of what you expect to happen. It's OK that you're not familiar with this, it doesn't happen often in programming
But now that you've encountered a bug, you might as well try your hand at this so-called debugging.
let me know if you need any hints
 
user6718998
1:03 PM
Yes, thx fr advice
 
omg this paperclip was always getting on my nerves xD
 
@Jerry you'll love this
 
n8_
1:54 PM
Paperclip!
Awesome shadow graphics...
 
Recursive c{c{c{bg}}}
 
2:16 PM
TIL a nested loop can outperform pandas by a factor of nearly 2x.
 
2:27 PM
It’s not really the nested loop that’s faster, but the JIT compiler and parallel processing that Numba leverages, right?
 
(yes), but you still write it as a nested loop which the JIT parallelises
 
doesn't the jit turn python loops into c loops?
 
surely that isn't all it does?
 
Of course not. But it also does that. And it's not loops that are slow per se: python loops are
Under the hood most things are loops
 
cbg
anyone else having issues with github not loading the CSS (?) or letting you perform any actions, when you're signed in, and telling you you signed in/out somewhere else and to reload?
 
2:34 PM
okay, I realise I didn't word that right. I should've said it's mind boggling how a vectorised version of a hand-written loop would do so much better than numpy's
again, not that much better, but good enough to impress me (yes, I'm easily impressed)
 
2:50 PM
@toonarmycaptain can't check now but have you tried clearing your cookies?
 
if that doesn't work, blame caching
 
making python faster is always impressive ;)
 
cabbage
 
@W.Dodge you're aware that python is infamously slow, right? :P
less dev hours, more runtime
 
can someone help me out with flask and flask_login? i have a flask app with gunicorn and nginx and get my user constantly logged out, why happend this?
 
2:54 PM
Numpy can be fast but only because it's written in c
 
@W.Dodge making numpy* faster is more impressive, methinks
I enjoy reading piR's and Divakar's answers
those guys really know how to do it
 
@AndrasDeak yes that was sort of my point. Anything done to ameliorate python's slowness is good in the long run
@coldspeed making the already fast numpy faster is impressive, indeed! Hey while I have your attention I have a silly question: what was your old avatar? I was trying to remember the other day (for some stupid reason) and it bothered me that I couldn't. I know it was black and white, was it as skull or something?
 
I've had this one for almost 6 months. My previous avatar was the identicon; and before that, a cat with a monocle and pipe
I can't remember if there was anything else. Definitely no skulls, not into that sorta thing :D
 
3:17 PM
@coldspeed Didn't you have L for a while?
 
Oh yes. I had L, and chibi L for sometime too.
But that last year, I think.
 
n8_
if there a method/function to convert a csv to UTF-8?
or could I use something like `def utf_8_encoder(infile):
for line in infile:
yield line.encode('utf-8')`
in python, that is
 
3:40 PM
@davidism hi bro, how can solve this problem: flask_login drop the session randomly and redirect me to login form even if i logged in?, later get error AnonymousUserMixin has no role_id. i have the app in ubuntu server with nginx and gunicorn, i run the app in window and work great, why happend that in ubuntu?
@davidism i triyed removing @login_required from url but when i need register some data, i need an attribute of the user that is get in current_user. how can avoid flask remove current_user?
 
yeah..
cabbages
 
@piRSquared Next possible canonical: Demystifying query and eval. Seriously. These functions are way too underrated.
 
@coldspeed hah. especially since for larger sizes they are performant
 
and they support substring checking! (among many other things that I'd love to learn)
 
4:19 PM
This statement in Day12's question "For brevity, in this example, only the combinations which do produce a plant are listed." and my tiredness last night left me baffled by what was supposed to happen. Amazing what a good nights sleep can do.
 
@AndrasDeak Yes. And restarting browser.
Might be the network I'm on. Works fine on my phone, which is a pain.
 
Have what is probably a basic question. I am trying to use watchdog in to monitor a remote windows file server but I am having problems getting the directory to be recognized. Is using watchdog the right approach or should I be using a different method?
 
n8_
Can someone explain why df.loc[(df['VitalStatus'] == 'Alive') & (df['CauseOfDeath'].notnull())] where VitalStatus and CauseOfDeath are columns in my df
is returning TypeError: 'Series' object is not callable
 
@n8_ Do you have a column named "loc"?
 
only thing you are calling is df['CauseOfDeath'].notnull() Did you make a column named notnull?
 
4:29 PM
...hmm, that's probably not it ^^
 
n8_
No, sorry, I am assigning that line of code to a df. so ` invalid_df = df.loc[(df['VitalStatus'] == 'Alive') & (df['CauseOfDeath'].notna() == True)]`
 
that shouldn't do it either but idk. Need MCVE stat
 
n8_
This has worked for numerous checks, except the notna() portion
is throwing that error
 
@VictorAlvarado don't ping users out of the blue. That's rude, bro
 
^ totally @login_required hates it when you do that
 
4:31 PM
:|
 
come on... I know you chuckled on the inside
 
n8_
my last message, I added that `== True', get the same error
I've also tried notnull()
 
notnull and notna should produce the same results. They are both Series methods that return boolean Series. You don't need to use == True though it doesn't hurt
 
n8_
Gotcha
 
Try df['CauseOfDeath'].notna()... do you get an error
 
4:36 PM
It hurts
Don't test booleans for themselves
 
n8_
Well, I added it after to test but got an error either way
@piRSquared, yup, notna() gives the same Series error
It's weird because `invalid_df = df.loc[(df['VitalStatus'] == 'Alive') & (df['AgeAtDeath'] > 0)]' works just fine
 
Now run type(df['CauseOfDeath'].notna)
You've done something goofy to your dataframe. I'm trying to figure out what so you don't do it again
 
n8_
ok, one sec
 
have you tried turning it off and on again?
(your interpreter, I mean)
 
Hey guys
 
4:39 PM
I suspect that you've assigned another series to the attribute 'notna' of the Series object df['CauseOfDeath']
 
n8_
would it matter that it is in a function?
type(df['CauseOfDeath'].notna) returns method
I pulled the code out of the function, fyi
 
hmm, that's correct.
yeah, need an mcve to move on. Otherwise I grasping at straws
 
n8_
gotcha
restarted, still the same issue. And other functions are working fine. I'll continue to troubleshoot and post if I can't figure it out. Thanks guys
 
sorry I couldn't be more helpful
 
n8_
No worries at all!
 
4:50 PM
cbg
 
cbg
 
potato
 
Hun. so I pass an object to a named parameter of the routes library definitions. once the route matches however, that instance is a string, according to the debugger controller = {str} '<Namespace.Foo.Bar.Baz object at 0x7f886ef7d898>'. I'm probably doing something funky, but how should I access that actual object? After a route matches, I want to invoke the action passed in parameters on that controller.
 
If I wanted numpy arrays that represent indices of a 3D grid, I can do this i, j, k = np.indices((300, 300, 300)).reshape(3, -1) Is there a cleaner/faster way
 
wim
^ the original bug (disclaimer: maybe urban legend)
 
5:14 PM
Quick question about list and pop(). I have a set of test inputs for my AoC stuff but when I’m trying to figure out what the heck I’m doing I’ll assign the test input to an argument so I can run the internals of my answer function in the interpreter interactively. I recently noticed something that I should ask about, however. What is happening in the following code? :
>>> a = [1,2,3]
>>> b = a
>>> b.pop(0)
1
>>> a
[2, 3]
 
you are removing the 0th element from this list
 
I don't understand how list a is still connected to list b
I pop b and a changes
 
You have a dog with 3 legs. You put the name tag "a" on the dog. Then you also put the name tag "b" on the same dog. You rip off one of the dog's legs. The result is a dog with 2 legs and 2 name tags, "a" and "b".
 
hey
do this
id(a)
id(b)
you will get the same address
because they both are sharing the same address
 
not the dog! D: But yes, names are just that, names. when you assign, you always put a tag on the real object. b = a is just putting the name b to the OBJECT that was referred to by name a.
 
5:17 PM
they are not two different
this is why, you make changes in b, also made changes in a
 
Okay, thanks for the examples and clarification.
 
@W.Dodge Did you get it?
did you try it on python
 
wim
But I didn't put the nametag b on the dog. I put the nametag b on the nametag a.
 
>>> id(a)
140474999798664
>>> id(b)
140474999798664
 
this id function>
greattt!!
my question now :D
I am creating a virtualenv using conda
but after creating one, when I execute pip lits
 
5:21 PM
there is no concept of nametagging a nametag. everything on the right hand side gets "evaluated" first. a nametag evaluates to its object.
 
list*
it shows all the packages installed in virtual env which are installed in base
 
wim
But everything in Python is an object. That includes nametags.
 
and when I execute conda list
it shows none
 
Why should that matter? if its on the right, it is evaluated.
 
@piRSquared i,j,k = np.mgrid[:300,:300,:300]
 
5:23 PM
and when I try to import any library in virtualv env which I didn't install in virtualenv but is installed in base, it is able to import it. why
 
did you activate your virtual environment?
 
yes I did
 
@W.Dodge variables vs names
Bah, link broken now
 
I'll google that, gracias
 
The good one ^ is still there, sorry
 
5:31 PM
my solution
conda install pip
fixed it
 
wim
ned is really good at explaining things
@AndrasDeak do you have a good intuition about when stride_tricks can be used and when they are not gonna work? The interface is confusing so I'm always figure them out with trial and error
 
I am a bit lost using context managers for transactions. is there any way for __exit__ to get the object returned by __enter__?
 
wim
and the docs are lame:
> it is advisable to avoid as_strided when possible.
like "we couldn't be bothered to write a good interface so let's just advise people to avoid it"... what?
 
@wim I only use it for sliding windows
 
wim
@MisterMiyagi usually __enter__ returns self
 
5:40 PM
I think they discourage its use because it's easy to corrupt your memory or read garbage at least
 
wim
if you really want to return something else, just setattr it as self.the_thing
 
Too easy
 
wim
right but that's exactly because the interface is balls
 
I probably wouldn't put it in prod
@wim just very low-level :D
very generic
 
wim
well it receives the array, shape and strides as input - it should be possible to tell if a given stride could segfault, wouldn't it?
 
5:44 PM
@wim the context may be re-entered concurrently, so there may be more than one "thing" active at any time
basically I want to avoid explicitly conjuring up a separate context, i.e. replace async with condition.context with async with condition
 
wim
@MisterMiyagi doesn't make sense to me. it's still the same context manager even if it's re-entrant.
the as thing part is just a dumb convenience
 
@wim looking at shares_memory that's not very easy
and would you allow slicing data? Viewing ints as multiple uint8s while you're at it
One might or might not want that
 
@wim yes I know, that's kind of my problem I guess...
think about how for creates a new iterator every time
I would need with to create a new context every time
 
It would probably take too long to solve the Diophantine equations to determine validity at runtime
 
Hi, would I get a before assignment error if I were to sub this: ``` try:
trade = cli.place_limit_order(price=price, side='buy', size=size, product_id=product)
return trade
except:
# TODO: log the exception
trade = limit_buy(price, size, product, cli, count+1)
return trade``` for just returning `trade` at the end instead of returning in try and except
given that it is not declared outside of the try except
 
5:58 PM
@isquared-KeepitReal please see sopython.com/wiki/…
 
@isquared-KeepitReal looks like trade is always defined before your return it
so that should work
is the trade = limit_by(... part of the except: clause?
 
but change the bare except
You rarely want to catch everything (without reraising)
 
try:
    trade = cli.place_limit_order(price=price, side='buy', size=size, product_id=product)
except ExpectedException:
    # TODO: log the exception
    trade = limit_buy(price, size, product, cli, count+1)
return trade
if you define trade on all paths of the try, you can use a single return
that makes it easier to see that the return happens regardless of what the try block does
 
@MisterMiyagi yeah it's like that. thanks
I thought that link was for explanation of why that would work lol
but it is useful, nevertheless)
 
I want a hat
 
6:18 PM
@AndrasDeak thx
 
@AnttiHaapala Hat distribution is pretty odd this year. In the past years, I would already have around 5 hats by now.
 
I have a 10 different types of xml files associated with an 'object', size is in KB's. I need pieces of information from the files. They have different tree structures, and I need to extract 'Text' from elements at different levels of nesting. I am looking for recommendations on how to document requirements per xml for a developer.
 
what do you mean by requirements? for the document, as in XSD? or what to do with it?
 
#StHatOverflow
 
6:37 PM
@poke I wasn't awarded a hat for making 20 reviews either.
neither this one: Top(bar) Hat
earn rep for an answer or get an answer
 
wim
Actually had a stackhat in my childhood. might be an Australian thing?
 
that dangerously looks like a hockey helmet
 
@MisterMiyagi Like, for now I'm thinking I'll make a list with two columns 'Element Name' and 'Path' to the elements. For each type of xml.
 
wim
@AndrasDeak day 12 did you actually get any speedup for all that crazy numpy?
 
6:56 PM
@wim probably not, but it was easiest for me to implement. As I said it's much slower than your native
It worked like a charm the first try which wouldn't have happened otherwise
 
@wim You used the name tag "a" to put the name tag "b" on the dog. You didn't put the name tag on the other name tag.
 
Stop torturing that poor animal
 
You called the dog by his name ("a") and then put another name tag on him
 
now you don't need to do it
 
I never liked the python logo
 
7:03 PM
hmm
one of the hats require you to visit teams page...
... except that you need to visit the teams.
i.e. throw in your credit card etc.
 
There's free trial
 
to print a dictionary with format() is like this one:
print ("{a} and another one {b}".format(**diction))
Can I also print an extra variable using format in the same print statement ?
I mean, I tried it showed error...Is there any other way ?
print ("{a} and another one {b}, goes a variable {0}".format(**diction, "pqr"))
 
Positional before keyword
 
print("{a} {b} {0}".format("pqr", **diction))
 
or name that too as a keyword
 
7:07 PM
ok, you mean "{a}".format(a="pqr") , like that !
 
Yup
But a is taken in your example
Avoid keys in diction
 
but, isn't that the better way ?
to be able to use keys
 
I just meant {c} and then c="pqr". Otherwise keys clash.
 
ohh, alright ...well ! yeah that value was for that example only
otherwise , its been taken of , not clashes
*no
 
@AseemYadav or just use the fstrings :P
print(f"{diction['a']} {diction['b']} {c}")
 
7:40 PM
only problem is that I'm using py2.7
but yeah, not for so long
2020 is almost here ;)
 
7:54 PM
January first, 2020: all python 2 code automatically converts itself to 3.8
 
@AndrasDeak Genie: That one's on me, still three to go.
@MisterMiyagi I don't know anything about async, but can't you just cache __enter__ and call it in __exit__ again?
 
Late cbg
 
@Arne Please no. It'd be much more readable if you just store the thing in an attribute of self
 
8:10 PM
You're right, I don't see a reason why that shouldn't be possible
Maybe someone decided declaring members outside of __init__ is the worst antipattern ever, so people have to make do
 
Because the attributes of the object would change during its lifetime, essentially implementing it with built-in monkeypatching?
 
pyCharm keeps pestering me about that :(
You can just initialize it to None or whatever though
 
I'd accept that
 
cbg
 
cbg
 
8:24 PM
A bit broader than my question yesterday, is there anyone who understands exactly what an app context is in Flask that can help me if I re-build an MCVE from my head-bashing-wall experience of today?
"Pushing an app context" apparently doesn't compute in my head in terms of decorators and even our own site seems to go round the houses to capture the context, but unfortunately I need it to work with a Session, not a custom user object
Without blueprints I think I kinda have the concept down, but using blueprints makes this "context" seem ephemeral to me :/
 
9:08 PM
I have a problem that's solved by code in the first three lines of this post. But I am not sure what is the argument new_xml to etree.ElementTree? stackoverflow.com/questions/38936531/…
 
Did you try figuring that out from the docs?
It seems to me that it should be another ElementTree object which is passed as the root node or something. Definitely not a string because strings don't have an iter attribute
 
I did but, normally attributes of `xml.etree.ElementTree` take an argument for a filepath or xml as string. Like

`import xml.etree.ElementTree as ET
tree = ET.parse('country_data.xml')`

Examples in the docs use ET.attribute(arg)..but this snippet ET(arg). Now talking about this has led me to believe arg in ET(arg) should be some kind of xml object
 
xml.etree.ElementTree is a module so it's probably indeed xml.etree.ElementTree.ElementTree that's in that SO question
 
@AndrasDeak that's Lxml.etree.ElementTree.ElementTree right? not xml.etree.ElementTree.ElementTree
 
how should I know?
 
9:23 PM
dir(lxml.etree.ElementTree.ElementTree) # object not found
 
what about lxml.etree.ElementTree?
 
same as the docs. Ok I think the reference you gave me will help, I'll figure it out.
 
lxml says it's "mostly compatible" with stdlib xml
their ElementTree class seems to have the same signature lxml.de/api/xml.etree.ElementTree.ElementTree-class.html
 
How has Martijn earned the "Still Fresh" hat, described as "be a user on the site for less than 6 months before Winter Bash, or join during Winter Bash; have earned at least 25 reputation"?
 
you can use hats from different sites
 
9:32 PM
Ah
 
hats... bah humbug and all that :p
 
yup :P
 
They seem to have arrived without as much fanfare as I think I remember from last year
 
it's like the company handing the kids spray cans and crack
"go have some fun, little Timmy"
 
Tiny Tim had a pretty rough paper round, you can't at least let him have some fun on crack? Monster.
 
9:37 PM
I've addressed concerns about some of the criteria needing hats but... it's all in good fun.
 
wim
@AnttiHaapala bribing people with hats
 
wim
@AndrasDeak aye, I had off-by-one error and got the punishment delay :(
hey @JonClements
 
heya @wim
 
wim
could you pls edit the pinned message to shortlink the join code to adventofcode.com/2018/leaderboard/private/view/119932
 
9:42 PM
@JonClements If I finally get you a sausage roll, is there a hat for that?
 
@roganjosh probably not, I'll just get you one after we have a few beers in M when I'm next there? :p
 
@wim oh yeah, me too, for part 2. What I meant was the dynamics was correct for part 1 (I almost never get them right first)
 
@JonClements Sounds good! There's even a Greggs right outside the station. Truly the stars align for such an auspicious occasion :)
 
@wim does that even work if you're not joined?
no, it does not
 
@roganjosh when's the next syzygy ?
 
9:46 PM
Checking to see whether that is technically confined to the solar system
 
wim
@AndrasDeak no (as was already established), but it's still useful for people already playing. and it doesn't go to a bad place for new visitors.
 
Oh, you mean keep the text and add the link. Sorry, not the first time today
 
wim
yeah aren't those called shortlink?

[shortlink](http://target/)
 
I have no idea
 
Hmmm, astrology is tougher than I thought. I've spent a whole two minutes so far trying to find a calendar
 
9:51 PM
@wim other way around mate
 
@JonClements I think he did it that way deliberately so it didn't compress into a shortlink but to demo the setup?
 
okie?
 
no, he did it right, but the line feed broke the markdown engine
 
<shrug> I can't find a calendar of syzygy events so I'm currently hammering out a vote of no confidence in Mystic Meg's abilities to tell fortunes
 
00:00 - 22:0022:00 - 00:00

« first day (2979 days earlier)      last day (1972 days later) »