« first day (3343 days earlier)      last day (1610 days later) » 
00:00 - 17:0017:00 - 00:00

5:00 PM
Detecting a probable return type without type annotations sounds extra double hard
 
I don't care for the T, so there's just await or nothing. Which still makes for duplicate code paths ATM. Which is bad since now I have multiple parameters like that...
 
Shouldn't the function be designed such that it's type consistent in some way?
 
I have a list of objects with integer values, let's say obj.location. As the end result, I need a list that has been ordered based on the difference of obj.location's in this list, smallest differences at the beginning. As an additional constraint, the first object of this list needs to remain in place. Say, my list has objects with their locations like this 10,1,44,2,12,3,13,20, then the resulting list would be of objects with locations 10,12,13,20,3,2,1,44
 
If the first one is fixed, just sort the others. Please specify what "based on the difference of obj.location's in this list" means in practice.
 
@AndrasDeak the problem is that I don't know which parameter is async or not. So either I have one function that is neutral to async, or I have 2**n_parameters functions that all do almost the same.
 
5:03 PM
The second item, 1, has distance [9, 0, 43, 1, 11, 2, 12, 19] from every other value. Which one is used for positioning 1?
@MisterMiyagi can't you write a wrapper that handles these logistics based on argument type and calls something deterministic under the hood? I may be missing your point.
 
okay, the next item from the current item needs to be the closest item to the current one, and also be one that's not already sorted (no doubles)
 
Or, you know, don't mix sync and async in the same function? :P
@RandoHinn I don't understand at all, sorry
But it sounds like you can't use sorted. Instead you might have to loop over your list...
 
@AndrasDeak I can write the wrapper, but it always has to pay the worst case overhead, which is several intermediate iterators. As opposed to just doing nothing in the best case.
 
5:09 PM
I'll try for a 3rd time
 
@RandoHinn that's not what sorted is made for. It cannot handle such a case.
 
for every object in list, i need to find the object that has int obj.location closest to this object's location, make that the next object in the resulting list, then move on from that object. With no double-sorting allowed (see example above, where resulting list goes 20->3, because 13 has already been sorted as closest to 12)
You sure, sorted can't do that?
 
at least not directly. You can of course use sorted for each leading item.
 
So this is a nearest-neighbor type "sort"?
 
seems so
 
5:15 PM
nearest = sorted(tail, key=lambda item: head.id - item.id)[0]
you basically can do that for each pair of head, tail, with head = nearest and tail.remove(nearest) at each step.
 
Now I just got confused
 
Or head, *tail = ...
 
@JonClements like this?
 
@MisterMiyagi great, my 3rd rewrite missed a constraint
 
5:21 PM
@RandoHinn have you got some sample input/output ?
 
first object in values has to stay put
 
19 mins ago, by Andras Deak
If the first one is fixed, just sort the others. Please specify what "based on the difference of obj.location's in this list" means in practice.
leaving the first is trivial ^
 
the head never moves.
head, *tail = values
result = [head]
while tail:
    tail.sort(key=lambda item: head.id - item.id)
    head, *tail = tail
    result.append(head)
forgot the initial item D:
 
@MisterMiyagi what changed?
ah
want me to trash the previous one?
 
yes, please
 
Perhaps key=lambda item: abs(head.id - item.id)
 
Wierd problems trying to save a pytorch tensor representing a 3x128x128 RGB image as a .png

Already know that I need to transpose the tensor by (1, 2, 0) to convert it into a 128x128x3 RGB image - pyplot can display the image no problem, but when I try to store the image with:

im = Image.fromarray(tensor.numpy(), 'RGB')
im.show()

I get a scrambled mess
 
im.show() doesn't sound like "store" to me
what are you really trying to do?
 
calling im.save(filename) but the resulting .png and the scrambled mess I see with .show() are the same
 
If the saved result and the .show() show the same scrambled thing then your issue is not with saving.
Any chance that Image.fromarray needs the same transpose that I see you're not using?
 
5:35 PM
That has already been done
 
so the tensor in tensor.numpy() has dimensions (128, 128, 3)?
 
@MisterMiyagi allmost working
 
@RandoHinn see @PaulMcG's suggestion if you haven't already.
 
Aand perfection
 
example = output[0].cpu().detach()
example = example[1:4].numpy().transpose(1,2,0) #extract RGB from the image (Depth, RGB)
plt.imshow(example)
plt.show() #displays correct image
Image.fromarray(example, 'RGB').show() #scrambled mess
 
5:37 PM
Then check how Image.fromarray behaves with int vs float-valued arrays for RGB images. Pyplot expects floats to be in the [0, 1] range and ints to be in the [0, 255] range
there might be something similar going on, i.e. the data being interpreted wrong
if you don't find anything maybe others will be able to help, I've never used pillow
 
Hmh it COULD be that ... RGB might expect values in [0,255] while I definetly display values in [0,1]
https://pillow.readthedocs.io/en/3.1.x/handbook/concepts.html#concept-modes

Seems to not allow for float RGB values ... does it?
F does not work ...
 
well you can always try if (example*255).astype(np.uint8) changes anything
that would map your [0, 1] floats to [0, 255] ints
 
That solved it!
Nice ... thank you!
 
no problem
I think a .round() might be better added there in the middle...
otherwise you're probably biased toward 0
 
Well a value close to 0 to be clamped to 0 would be better for an image representing an object inside a void
 
5:47 PM
but my original would convert 0.99999 to 0 rather than 1 after the multiplication and conversion
(example*255).round().astype(np.uint8) is probably better for this reason
For instance, you could only get a 255 pixel with an exact float 1.0 with my first version
 
(example*255+0.5).astype(np.uint8) would accomplish the same as round() without the function call.
 
too hacky for my taste, for little benefit
 
It is fine it only happens once every 4 minutes so if one thing is faster by a few miliseconds I don't care
 
Hmm, so there's this deque thing in collections that I saw with defaultdict. Does it sound feasible to use that to cue directions, calling deque.rotate(x) with x positive/negative 1 for right and left turns?
 
(and I don't believe hacks like that and stop and think if it's correct :P)
 
5:51 PM
I just store one example of my dataset every epoch so I can see the progress my autoencoder and/or gan makes
 
@toonarmycaptain you can use it as a ring buffer, but it's really overkill for just 4 items.
 
umm... cosmic brain is quite a fancy name for a bronze badge...
 
context?
 
How come star unpacking works i = complex(*(1,2)) but when I link it to an argument it says "TypeError: complex() first argument must be a string or a number, not 'tuple'"
 
Define "link it to an argument"
 
5:53 PM
@salbeira if you're referring to what I said - hats...
 
@toonarmycaptain because you haven't unpacked the tuple...
 
Another quick Q. An easier on this time :D
List of objects, need to find if a specific value is set as any of the object's something field - can a in do this directly somehow or do I need to loop over the list and extract all the fields I want to compare first/run a compare in the loop?
 
as in any(obj.something == value for obj in objects)?
 
I think it's more about getattr
any(getattr(obj, fieldname) == value for fieldname in every_fieldname)
where you'd set every_fieldname = 'first_possible_attr', 'second_attr' etc.
 
6:10 PM
any works, ty
 
I'll stop extrapolating from unclear premises
 
6:45 PM
    i == complex(*some_tuple) # this works outside of a class in the interpreter.

    def __init__(self, some_tuple):
        self.i == complex(*some_tuple)
 
Don't forget the self argument comes first (before some_tuple)
Probably want just =, not ==
 
Probably. I just typed this out without the rest of the args
 
Assuming that __init__ is in a class named SomeClass, are you creating an instance using SomeClass(1,2) or SomeClass((1,2))?
 
Until an MCVE materializes I'm going to blame "floating point imprecision"
 
Hmm now it's working. I think I forgot to reimprt it into my repl :/
 
6:51 PM
the #1 culprit when two numbers should compare equal, but don't
 
7:10 PM
It may be helpful to know that you can create complex numbers without using the complex name, using the j literal suffix
>>> type(1+2j)
<class 'complex'>
 
user11867329
Would I need additional python modules to do this:
 
The csv module is usually pretty good at reading csv files. You don't have to use it though, if you're confident that you can parse it yourself
 
here's my code bpaste.net/show/AUSQQ and the issue which I'm in is am trying to insert datasets variable to the csv file for each provider but it's causing wrong output.
 
If you know with 100% certainty that the csv data is exactly and only numbers, then you can probably get away with just splitting each line by commas
 
7:20 PM
datasets can be line or more for each provider and this is the point which causing the issue as i think but i don't know how to fix.
 
@Arne I added your riddle, but you may want to add a hint/explanation (or come up with a better title than I did)
Make sure you're wearing safety equipment and are properly strapped into your seat before you press "edit" though. It's a bit of a mess
 
@αԋɱҽԃαмєяιcαη for item in data, datasets: final.append(item) looks weird to me. That's effectively equivalent to final = [data, datasets]. Is that what you want?
 
Finally had a chance to work on AoC and my asteroid detector passes all tests but the last on for part A. I made a visual and things look right. I'm counting a few extra asteroids that should be blocked.
Made a gif of my o(n*abagillion) approach of checking each asteroid against all others
 
7:36 PM
trippy
 
rep indicator's become blue
 
@Aran-Fey thanks, I like it the way it is =)
 
 
I also still can't edit
@cs95 w..why don't you click it
 
i use it to test my patience
 
7:41 PM
nevermind
 
you show unreasonable levels of constraint already, I think it's time to click it
 
it's blue
da ba dee da ba dai
 
*kicks angel off your other shoulder*
 
it was blue after the redesign, as a bug
 
DONTCLICK!!11!
 
i usually end up hitting r on accident at some point which dismisses it
that's the one ^^
 
user11867329
7:54 PM
Isn't there a standard XML map schema that exists where it simply takes first row to create values, then just:

<records>
<record index="1">
<Value1>1</Value1>
<Value2>2</Value2>
<Value3>3</Value3>
<Value4>4</Value4>
<Value5>5</Value5>
</record>
<record index="2">
<Value1>2</Value1>
<Value2></Value2>
<Value3>3</Value3>
<Value4></Value4>
<Value5>5</Value5>
</record>
 
@OakDev Not that I've ever seen. I rank the task of creating one yourself at a difficulty level of 3/10.
 
user11867329
I'm just appalled there's not one online
 
If you have a clear design in mind you could have written an implementation in the time it took you to describe the problem to us
 
yesterday, by Kevin
Not all code can be found online, sometimes you have to write it yourself ;-)
 
(Which is not to say that coming up with a clear design is trivial. This is often the hardest part)
 
user11867329
7:57 PM
It isn't in my case, I just don't know where to start
 
hi, i am looking to read and write to a csv file online - i have tried github and i can read the file but i cant work out how to write. it doesnt have to be on github just somewhere that can be executed from anywhere?
is this possible?
 
@ThelurkerLurker How committed are you to keeping it a csv? If it can be any kind of "tabular data" format, perhaps you could use Google Sheets, which has an API for both writing and reading.
 
ah ok. i will look that up! thank you
 
@ThelurkerLurker gspread is a fairly decent wrapper
 
8:01 PM
thank you!
 
On a similar topic, I decided today that I'm done with parsing a bajillion spreadsheets, I'd rather have something embedded in my app that I can just replace the existing spreadsheets with, but with my own validation as data is entered. I've settled with jexcel for now to start researching the event hooks. I don't suppose anyone has done something similar and has other suggestions?
 
@OakDev Don't be too appalled - XML schemas support such variety it would be hard to unify around a single "standard XML map schema".
On the csv import side, I wrote a package called littletable that makes this stuff pretty easy, and gives you a list-like collection for navigation in your Python code.
>>> import littletable
>>> lt = littletable.Table().csv_import ("""Value1,Value2,Value3,Value4,Value5
... 1,2,3,4,5
... 2,,3,,5
... 5,4,,2,1""")
From there you can use something like elementree to push out whatever XML structure you like
 
stackoverflow.com/questions/59293075/… needs clarity. No point in it just attracting more downvotes
 
closed
 
Thanks
 
8:15 PM
Did anyone else's AoC for today print upside down?
 
Sorry, didn't think that qualified as a spoiler, since it's absolutely possible that my 'solution' looks like upside down kanji....and is in fact junk.
 
I think we've settled on "things you can determine from the part 1 description aren't spoilers". Part one shows how you might display the result of your computation two dimensionally, so it's not unreasonable to talk about how your particular implementation displayed the grid upside down
Perhaps it's a small spoiler to indicate that one of the solutions depends on such a visualization
 
I opened it up, saw that it needed intcode, and closed it back down.
I'll do it once I get home, where I have the latest version of my IntcodeInterpreter.
 
I'm still on Day 6. Just solved part 1 this morning.
@KieranMoynihan that's what GitHub is for =p
 
8:23 PM
I haven't displayed any 2d answers upside down this year, but only because I triple check any logic having to do with compass directions or clockwise/counterclockwiseness, since both of them care about the orientation of your unit vectors
 
@Code-Apprentice I have the day 5 and day 7 versions on github, but no day 9.
 
Math textbooks usually orient their graphs so that "up" is in the positive Y direction. Many computer graphics systems, image formats, and AOC questions put "up" in the negative Y direction.
00's era Kevin made enough coordinate mismatch errors for one lifetime, and now '10's Kevin is infused with Constant Vigilance
 
@Kevin Eh? Is that so? I'm so far behind on AOC but I mean in terms of image formats
 
Yeah. gif and png put their origins at the top-left of the image, I'm pretty sure. I think bmp sides with math textbooks and puts its origin at the bottom left.
 
Is there any practical reason for it being in the top-left?
 
8:30 PM
Ahh, ok, now I think I get it. Wasn't there a blog post recently by a professor talking about their biggest mistakes and one was that they had some draggable circle and they decided to put the anchor in the top left rather than the center?
For her sprites for a bouncing ball IIRC
 
@KieranMoynihan Arguably, it matches human intuition about the direction that linear data should flow. After all, the majority of written languages go left to right, top to bottom. Why not image data too?
 
Arguably.
But I believe there are certain language groups that would disagree with that.
 
(Which is not to say that LTR somehow matches intuition on an instinctual biological level. It's sufficient that LTR is drilled into the minds of anyone that grows up in an LTR society)
 
@KieranMoynihan Primarily this is due to historical reasons and hardware implementations. Specifically scanlines in a CRT monitor are rendered from the top to the bottom.
 
Found it. In the "App Inventor" section
 
user11867329
8:36 PM
Hey! That's amazing. I mean, the csv to XML is basically:

1. Create row index based on how many first row values
2. Populate with values
 
@Code-Apprentice Not an expert on cathode ray tubes here, but could you not just as easily orient the CRT hardware in the opposite direction, and have it fill right to left, bottom to top?
 
wim
>>> ts = 1234567890.
>>> datetime.utcfromtimestamp(ts).timestamp() == ts
False
timezones .. endless source of amusement
 
@KieranMoynihan probably the direction is an arbitrary choice made by the hardware designer. Someone in ancient history chose top-to-bottom and it stuck.
 
@Code-Apprentice And yet mathematicians decided on bottom-to-top y-coordinate orientation for some reason...
 
user11867329
Every single script I see, even awk scripts, it's always like: Here' my script that works for my file. Like, bravo.
 
8:38 PM
@KieranMoynihan yup, two parallel histories that collide when we start writing programs to render geometric objects on a modern screen.
 
Electrons are said to be negatively charged despite this contradicting our intuition about what positive/negative mean, but changing the terminology would require about three centuries worth of white-out
 
what is your source for intuition here? I'm not sure I have any "intuition" about the word to use for the charge of an electron.
science is interesting that way...it almost always defies intuition or "common sense"
 
It's actually making me curious now why we drag items from the top-left corner rather than bottom left. The latter feels unintuitive to think about, but I'd bet a large portion of that is simply my conditioning from always interacting with top-left
 
@Code-Apprentice Ok, you caught me. I don't have any intuition one way or the other, I'm just repeating something I read online: xkcd.com/567
 
72
A: Why is the charge naming convention wrong?

endolithIt's not a mistake, and conventional current is not wrong or backwards. Electric current is often thought to be a flow of electrons, but this is wrong. Electric current is a flow of electric charge. Charge can be positive (protons) or negative (electrons), and both types of charged particles ca...

 
8:42 PM
@Kevin ok, that makes sense. If you are "taking a charge away" from a surface, then it would make sense to say the surface is negatively charged.
 
I expect that the intuition is "in a system with a positive and negative quantity of something, objects typically flow from the positive area to the negative". Objects with high altitude fall to areas of low altitude. A gas with a high density spreads into an area of low density.
But electrons in an area of high positive charge do not flow into areas of low positive charge.
 
@Kevin If "negative" means "low positive" then yes, that would be true.
 
@Kevin That's a coin-flip of terminology. Electrons in a region of a highly negative charge might flow into a region of low negative charge
Mmm, actually, I'm contradicting myself
 
Although "high negative charge" is a coherent concept, "negative" carries an inherent connotation of lowness, so a reader may do a double-take when looking at a phrase that ostensibly says "high low charge"
 
Well, there's a Quora on this
 
8:48 PM
If I had a time machine, I'd encourage Ben Franklin to pick terms that have nothing to do with positive or negative, to avoid any implication of directionality
 
And, anti-matter just makes a mockery of the naming logic in hindsight, I guess. But the names were chosen before it was known to exist...
@Kevin that's probably why we moved on to "charm" and "strange" :P
 
We learned our lesson :>
Next time around we're naming the particles bleggtron/neutron/grubetron
grubetrons flow from areas of high grube to areas of low grube
or, equivalently, from grubeful areas to bleggful areas
 
9:11 PM
@OakDev time to learn a language and use it on your own
 
user11867329
@AndrasDeak Took me about 10 years to properly learn english
 
user11867329
in 10 years the language I'm learning won't exist
 
@roganjosh written text?
Unless I lost the thread
 
grrr... my WINE has borked itself... no idea... purged it, winetricks and litrus, reinstalled all the latest versions and it just won't successfully install MTG Arena again... weeps
 
@AndrasDeak Yeah, I realised after I said it that there was another debate going where Kevin mentioned that, and there was an obvious dispute raised that there's a (sizeable) population which would disagree with that being intuitive :)
I just stopped for a second to ponder whether it would seem a bit wonky to Arabic speakers (right-to-left) or Chinese speakers (top to bottom) but then I think about how window commands like resize or close are in the top right on Windows and that probably never bothered me
 
wim
9:28 PM
@AndrasDeak blind, but active
 
could someone advise, am trying to print the tree as it's on the website. repl.it/@AmericanY/coco
 
I don't follow at all.
 
geez, finally figured out what was wrong with my asteroid detector, floating point error in equality comparison was letting a few asteroids slip by
 
wim
@MisterMiyagi ewww
 
@αԋɱҽԃαмєяιcαη I'm looking at the [page source](view-source:db.nomics.world/BDF/MNA) and there's only a single mention of "tree", and it's not a <div> id
 
9:39 PM
yeah, that markdown will probably not work
 
So I'm finding out :/
 
it's picky about protocols
 
@roganjosh link is https://db.nomics.world/BDF
 
For Chrome, at least, it works, so I guess I'll leave it since it should be obvious what I'm trying to refer to
 
without /MNA/
Reserve assets template [BDF/RA_T]
CEFIT : Loans and Deposits in French Regions [BDF/CFTDC]
FATS Outwards [BDF/FATSO]
Loans and Deposits in French Regions [BDF/CEFIT]
Interest Rates - Euro area [BDF/MIR]
the output should looks like the previous.
 
9:42 PM
Ok, so what actually happens?
 
the output now is
Reserve assets template
[BDF/RA_T]
and so on
got it?
 
Nope
 
wim
@toonarmycaptain Yes. Because I used complex numbers, where the +1j unit vector is pointing upward not downward.
 
if you did run the code here repl.it/@AmericanY/coco
you will see the output.
it's different than what on the website. and am trying to make it same as website.
 
wim
easily fixed by np.flipud though.
 
9:44 PM
Right. I really don't do a lot of web scraping but it seems that you need the contents of <a> to get rid of the extraneous detail inside the first loop
You should look at the source. It appears that you're also getting the data inside the <span> tag
 
wim
@Code-Apprentice The cathode rays down in australia render from bottom to top, though.
 
@wim that's just a verbose way to slice the first dimension backwards :P
 
what I'm having now is the correct output. but i want to solve the point of the line break
solved it.
for item in soup.findAll('li', {'class': 'my-4'}):
    print(item.get_text(strip=True).replace('\n', ''))
 
wim
@AndrasDeak I guess
Hey, while I was writing the lines just above that spot I wondered if you might have a better numpy trick there.
 
@αԋɱҽԃαмєяιcαη Nice. I was just trying to get my head around the solution but I probably was never in a position to help :P
 
9:53 PM
in MATLAB I used flipud and the like a few times, but in MATLAB you'd have to explicitly say arr(end:-1:1, 1:end) which is meh
 
wim
And also on that line, isn't there a way I can do it without unpacking to vectors?
I got annoyed trying to figure out the broadcasting
 
@roganjosh :P you already helped me by letting me to think to get the data from another place in the source :P thanks
 
@wim Ah. Also, it was fun trying to wrangle typehints so mypy didn't complain.
 
@wim not really I think, especially since you need to unpack the values. You could hide the unpacking of the rest by using full[tuple(rows_and_cols.T)] or something, but that's essentially the same thing less readable. The only thing you might do is use sparse.min() to compute both minima in one sitting.
@wim and which one's that exactly? The two whiles?
 
Apparently You shouldn't hint DefaultDict just Dict, and apparently don't pass max(set) to range.
 
wim
9:57 PM
the guys good in numpy broadcasting must get leaderboard spots all the time
it saves so much
 
This year has been very low on numpy juice so far :(
 
wim
@AndrasDeak yes, maybe there is something like the opposite of np.pad ?
 
yeah, there's definitely a better way, let me think
 
wim
np.unpad ... :D
 
there's np.trim_zeros for 1d, promising
why -2: rather than -1 in while not full[:, -2:].any():?
 
wim
10:01 PM
because the glyphs each have a column of fat github.com/wimglenn/advent-of-code-wim/blob/…
 
ah, OK
 
wim
well, the small glyphs do. the big ones have 2 columns.
I wonder if I never saw W because it's too wide, lol
 
that would explain the lack of M as well
 
wim
yeah how am I supposed to spell my name now
 
@wim I think I'd use
>>> full = np.zeros((6,10), dtype=int)
... full[2:4, 2:6].flat = np.arange(2*4)
... full
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 1, 2, 3, 0, 0, 0, 0],
       [0, 0, 4, 5, 6, 7, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])

>>> inds = np.nonzero(full.astype(bool))[1]
... full = full[:, inds.min():inds.max() + 1]
... full
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 1, 2, 3],
       [4, 5, 6, 7],
probably less efficient, though
 
10:06 PM
@roganjosh just noticed that the issue is not solved hahah, I've just taken the data from inner tree. but left the title
 
I bet you could do the same login on sparse and create full with the correct shape in the first place
(you'd probably have to filter the vals)
s/login/logic/
@wim actually, just appending if v to the end of your listcomp will probably Just Work^TM
maybe use np.zeros((h+1, w+2), dtype=int) for the trailing fat column
 
10:33 PM
btw why is stderr redirected to dev null?
 
so that it doesn't print anything out
 
@aadibajpai context for that "btw"?
 
18 hours ago, by wim
@aadibajpai The code looks bad. Random commented out bits and dead code. Redirecting stderr to devnull and then not restoring it in a finally block. starts a thread then just joins it immediately. tests don't look to be testing anything.
so basically discard any errors?
 
18 hours ago :|
 
sort of, prevents them from being printed
 
10:36 PM
@AndrasDeak was asleep
also, github.com/SwagLyrics/SwSpotify/pulls wrt #13 and #14, is flask a better approach than a custom web server?
 
10:54 PM
Flask is not a web server
I'm reading through those threads but I really don't know what consideration I should have in mind
 
it's to handle requests from a chrome extension
I don't know if bundling flask is a better approach than the custom implementation
 
Ok, so I'll state it again; Flask is not a webserver
 
yeah I got that, it's a framework
 
So how can it handle requests?
 
well, it does have an inbuilt server, no?
 
10:58 PM
Yes, the one that is explicitly, almost-to-the-point-of-being-annoying, states that it is a development server and and should not be used in production
 
python has a built in web server too
 
yes but for the purposes here I think it works, nginx doesn't seem a smart choice for local communication
yes, one of those approaches uses http.server and writes its own methods
 
what about gunicorn?
 
^^ I can't follow that logic at all
 
wim
@AndrasDeak oh yeah. durrrrr
thanks
 
11:04 PM
@aadibajpai I can't speak for Flask, but someone in this room can. I think it would be a misstep to suggest shoehorning in the library for its development server. Even if it wasn't Flask, that approach seems wonky and uninformed
@aadibajpai even then, I don't think the dev server even comes from Flask, it's the werkzeug dev server
 
wim
I am getting dejavu
 
Probably. I'm pretty sure it's not the first time I've said such a thing, but I can't remember if it's the same problem and cba checking the history.
Scanning the main feed: "Adding an elemnt in a list with for loop" immediately followed by "Pyhton AttributeError (flappy bird game)". Time to try find a new Netflix series. rbrb
 
Glow is an interesting one
 
wim
@AaronHall yes, sure. it's like the late binding bug that bites lambda users
this is what the failure mode looks like
>>> from collections import defaultdict
... def vivdict():
...     return defaultdict(vivdict)
...
>>> d = vivdict()
>>> d['k'][42]['potato']
defaultdict(<function __main__.vivdict()>, {})
>>> vivdict = 'oops this name went out of scope'
>>> d['now the existing instance is broken']
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

<ipython-input-7-9f5f050cd071> in vivdict()
      1 from collections import defaultdict
my recommended approach is to use a closure
def vivdict():
    def vivdict():
        return defaultdict(vivdict)
    return vivdict()
this gives the data structure a "private" reference to the name it needs to have access to in order for existing instances to keep working.
 
11:20 PM
I heard you like vivdicts so I put a vivdict in your vivdict...
 
wim
which is still sadly on 0 votes while the bugged lambda one from 2012 is on +154 ... :'(
 
is adventofcode worth doing? has anybody learnt anything new while doing it?
 
Definite yes.
mostly because it's fun :)
Although I think this year the puzzle creator has had the most fun. He's been coming up with pretty wild programs.
I fear the day when I'll have to actually understand the control flow of a program
 
wim
think he is picking stuff that will be fun to visualize on purpose. like asteroids and painting robots.
>>> A = np.arange(4*7).reshape(4,7)
>>> A
array([[ 0,  1,  2,  3,  4,  5,  6],
       [ 7,  8,  9, 10, 11, 12, 13],
       [14, 15, 16, 17, 18, 19, 20],
       [21, 22, 23, 24, 25, 26, 27]])
numpy got any efficient subarray check and/or find?
like
array([[ 8,  9],
       [15, 16],
       [22, 23]])
would be found at A[1:4, 1:3]
I know this is basically template match in OpenCV but maybe there is something directly in numpy?
 
11:57 PM
I've had to boot into Windows 10 to do a few bits... I feel like I need a shower (possibly in acid)
 
00:00 - 17:0017:00 - 00:00

« first day (3343 days earlier)      last day (1610 days later) »