« first day (2623 days earlier)      last day (2550 days later) » 
00:00 - 18:0018:00 - 00:00

I want actual '#' and '.'
you can subscribe to my patreon for commisions
DSM
DSM
@AndrasDeak: yours looks like it has a lot more high-level structure than mine does.
I'm actually walking around a matplotlib bug; calling tight_layout() completely changes the image. I'll figure out later whether the before or the after image is the buggy one :|
I'll have to pull the newest mpl first
DSM
DSM
Ah, maybe it's a resolution quirk. If I dump every pixel and then change the zoom, I can see some patterns more like yours.
18:05
could be some weird Moiré
hmm, perhaps my bug is actually just aliasing and neither are "wrong"
I should crank up the dpi
In [9]: fig.savefig('day21_finalstate.png',dpi=6000)
invalid command name "140240501946248idle_draw"
    while executing
"140240501946248idle_draw"
    ("after" script)
Segmentation fault
ooooops
ah, yeah, zooming in changes the picture
it's just the fractal pattern, probably
PIL would be better for this, I'm afraid
hmm, no PIL for 3.6?
DSM
DSM
I'm using pillow in 3.6 successfully.
oooh, I keep mixing those up
PIL which is actually pillow
thanks
DSM
DSM
@AndrasDeak: I only see things like this.
PIL is magic!
@DSM I was going to post that :)
DSM
DSM
This actually reminds me -- along with my adventures in nethack the other day -- of how useful visualization can be in debugging. I helped track down some very expensive bugs the other year just by plotting the time of certain files against their size.
18:18
Can someone explain why I see a '.0' in the groups() of this regex match?
>>> x
'inet 192.168.0.1 foo'
>>> re.search(r'inet\s+((\d+\.){3}\d+)\s+', x).groups()
('192.168.0.1', '0.')
sorry i meant '0.'
perhaps because you have an inner capturing group?
try turning that into a non-capturing group around ('d+'\.) assuming that's a thing in python regex
Because the parentheses in (\d+\.){3}\d+captures 192, then 168, then 0. But not 1, since the last \d+ matches that.
A capturing group that gets repeated will only have the last captured item. I learned that the hard way.
DSM
DSM
Point to Zed!
@AndrasDeak Yes, Python regex does have non-capturing groups.
In [15]: re.search(r'inet\s+((?:\d+\.){3}\d+)\s+', x).groups()
Out[15]: ('192.168.0.1',)
apparently it does ^
18:21
ah, so '0.' is the last item captured
thanks all !
18:43
are there are any good resources out there in terms of documenting flask routes (docstrings)?
19:03
so...48% of lights are switched on, but among ~5M pixels there are 400k contiguous clusters, the largest one having only 977 elements
@piRSquared Yes. I divided the image in quarters or nineths (depending on the size; if it is divisible by 4 you can process in quarters), and recurse.
When you get to a 2 x 2 or 3 x 3 piece, use the normal rotation-aware mapping. For anything larger, cache the result keyed on the input image.
@AndrasDeak is that in reference to todays AOC?
MCVE

        from string import ascii_uppercase
        mask = '   _ ______  _ __  ______ '

        ''.join(s if m == ' ' else m for s, m in zip(ascii_uppercase, mask))

 Is there a better recipe to mask a string?
Y'all are smart folks
19:13
results in 'ABC_E______LM_O__RS______Z'
Define "better". Are we code golfing?
''.join(map(lambda s,m:[m,s][m==' '],ascii_uppercase,mask))
up to you.
def mask(inp, msk, char=' ', replace=None):
    return ''.join(
        s if m == char else (replace or m)
        for s, m in zip(inp, msk)
    )
mask(ascii_uppercase, '   _ ______  _ __  ______ ', '_', '$')

'$$$D$FGHIJK$$N$PQ$$TUVWXY$'
I was thinking of slicing it, but I ended wanting some additional functionality
@Jfach so how's your port to 3.6 going? :P
19:53
@AndrasDeak no work has been done on the conversion yet... but I did bring it up at our year-end roadmapping session. "Management" ended up being on board for it, and we have agreed that all code we write going forward (until work starts on the conversion) will be written with 3 in mind :)
So it was a success!
That is really awesome! I'm happy for you :)
and good work getting it through
I have 16 hats, and I don't know how I got any of the secret ones besides the rep cap
read the meta
Oh, I found it
afternoon cabbage!
I can't believe I slept for most of the last 24 hours straight...
20:06
yes, this makes me very happy as well. I'm quite excited to start utilizing f strings in addition to some of the new async and shutil stuff :D
f strings are ones with {} in them right?
yes, but so do normal format strings
f strings are the strings that start with f
oh...I guess I haven't used them yet
20:14
>>> x = "world"
>>> f"Hello, {x}!"
'Hello, world!'
so like f'boo'
f'boo' is an f string, yes, although there's not much reason to make it an f string if you're not going to have any curly brackets in it
I have been using 'Hello, {}!.format('World') thinking this was an f string.
Are there any advantages to f strings over str.format?
less typing?
20:16
easier to read in many cases and actually faster as well
One less function call I expect
I just wrote this
ValueError(f'shape of msk {msk.shape} != {self.shape}')
Enough of an advantage to make an addition to the syntax of the language? Interesting
There are quite a few micro-optimisations they could do in that sense
I can't speak to the advisability of this, but it was convenient
    _fmt = lambda x: f'{x:{hfill}{alignment}{width}}'
python.org/dev/peps/pep-0498/#rationale talks about the justification
TLDR: percent formatting works on limited types and has surprising behavior around tuples; str.format is triple-wordy in the worst case
20:23
@cᴏʟᴅsᴘᴇᴇᴅ much much faster
(usually I guess)
and less redundant in a lot of cases (though entirely useless in other cases)
DSM
DSM
If memory serves we have Antti to thank for some of the speed. Personally I just like avoiding the duplication in the common cases, which was always ugly.
I found out just earlier today that you can nest brackets in .format specifiers:
>>> "{:*>{}}".format("Q",5)
'****Q'
>>> "{:*>{}}".format("Q",10)
'*********Q'
Perhaps I once knew this, but then forgot about it
DSM
DSM
I think I've only used it once in real code.
20:25
That's taking formatting to the next level.
(-: nested level
Every once in a while I want to pad a string to some particular dynamic width. Usually I write a pad function because I can't remember the built-in way(s) to do it
while len(s) < n: s = " " + s. No I don't care that it's O(N^2), I'm only padding to like 5.
Can't even be bothered to do s = " "*(n-len(s)) + s
DSM
DSM
I've been known to add an enormous pad buffer and then slice the result when I don't care about getting the arithmetic right.
20:31
(" "*n + s)[-n:] is nice and straightforward but you have to accept that pad("Hello", 2) will give you "lo"
DSM
DSM
ht.
pad = 40
align = '^'
thing = 'Hello my name is '
name  = 'Frank'
f'{thing:{align}{pad}}{name}'

'           Hello my name is             Frank'
99% of the time when I'm padding, I'm doing it based on the length of the largest possible string that will appear in that context, so. Doesn't really matter either way in that case
DSM
DSM
Is there a nice pad function in that other language you use?
(read "that other language" in the icy tone usually associated with the term "that other woman")
C# has PadLeft and PadRight, which I have an easier time remembering because they show up in the intellisense box when I type .pad. Javascript might have one but I can't say for sure because I forget literally every Javascript function except getElementById. I don't think KevinScript has one.
DSM
DSM
20:38
I've been doing a fair bit of C++ lately so I'm in no position to throw stones, as C++ string syntax is insane.
Google suggests that JS has padStart and padEnd.
20:51
there was something about a padsomething in some language
DSM
DSM
Probably Thai.
Woe to the language that names them leftPad and rightPad, that their users may never notice them when they type "P" in the autocomplete box
it was probably left-pad in node.js reddit.com/r/programming/comments/4bjss2/…
DSM
DSM
What, crickets? Fine, it was time to head out anyway. :-P
20:55
FWIW I got the joke :P
DSM
DSM
Thursday rhubarb for all -- time to brave the snow and ice.
rbrb for DSM
You forgot to put the <attempted humor> tag
@cᴏʟᴅsᴘᴇᴇᴅ this was provided to me by one of the members here a while ago:
>>> val = 42
>>> %timeit 'This is your number: %d' % val
204 ns ± 4.28 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

>>> %timeit 'This is your number: {}'.format(val)
277 ns ± 4.57 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

>>> %timeit f'This is your number: {val}'
11.9 ns ± 0.118 ns per loop (mean ± std. dev. of 7 runs, 100000000 loops each)
21:12
Nov 16 at 20:04, by Andras Deak
>>> val = 42
>>> %timeit 'This is your number: %d' % val
204 ns ± 4.28 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

>>> %timeit 'This is your number: {}'.format(val)
277 ns ± 4.57 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

>>> %timeit f'This is your number: {val}'
11.9 ns ± 0.118 ns per loop (mean ± std. dev. of 7 runs, 100000000 loops each)
it's good to see that the timings are so consistent
yeah... down the pixel
@cᴏʟᴅsᴘᴇᴇᴅ it wasn't faster, it was way slower originally, though it need not. bugs.python.org/issue27078
21:30
\o/ nice job Antti
i.e. I just went there and complained that guys this needs to be done for 3.6 final, and invented a name for the new opcode
@cᴏʟᴅsᴘᴇᴇᴅ likewise, poke invented the raise X from None syntax.
21:47
>>> f"Hello {'world'}"
'Hello world'
>>> import math
>>> math.tau
6.283185307179586
pep number 628 :P
meh
I'm more of a
In [10]: scipy.constants.physical_constants['shielded proton magn. moment to Bohr magneton ratio']
Out[10]: (0.001520993132, '', 1.6e-11)
guy
So matplotlib imgshow() shows the image, and returns an AxesImage object.
I want just the latter, not the showing. What's the best way to achieve that?
matplotlib.pyplot.imshow
(assuming a non-interactive shell)
pyplot.ioff() might disable interactivity anyway; never tried it
oh, you meant plt.imshow, didn't you?
That's.. unintuitive.
I'm building an animation.
Yes.
it's not exactly unintuitive; outside ipython/jupyter the default is that only plt.show() shows, everything else returns objects
blame those for enabling interactivity :)
21:56
@AndrasDeak that's the trick, actually. I had enabled inline display earlier. Removed that, re-ran the notebook. All good!
Only remaining issue is that repeat_delay doesn't appear to do anything.
@AnttiHaapala been using that in many of my AoC solutions.
python.org/dev/peps/pep-0562 mmm getattr in modules mmm
Inexplicably they dropped slots support, however.
Aw, GitHub doesn't show inline HTML5 videos in notebooks!
@MartijnPieters repeat=True
oh, that should be the default
22:10
recbg all
Finally on holiday!
I can't actually find that default True value in the source; perhaps it's a bug/inconsistency in the docs
@Martijn could you please try with explicit repeat=True?
#AoC2017 Day 21 generates images. So naturally I animated the results: https://t.co/D2IuPqOICM
@AndrasDeak no difference.
Probably the renderer.
thanks
@MartijnPieters I already have that open, but I don't use notebooks at all :)
also, your images likely have a bunch of artifacts because the real image is patterned on such a small scale
4 hours ago, by DSM
@AndrasDeak: I only see things like this.
both DSM and I got images like that using PIL for a pixel-resolved image ^
22:22
cbg. :)
OK, FuncAnimation inherits repeat=True from TimedAnimation
@Kevin not exactly geometric, but you might appreciate this still i.imgur.com/YgQnQRb.mp4
22:44
@AndrasDeak I can't help but think that the animator better take the rotation of the earth into consideration. :-P
yeah, the Coriolis force can be a real pain in the neck ;)
perhaps they're animating it on the Equator
 
1 hour later…
Hey, is there anything stopping me from using Django to create a completely standalone and offline app?
No. I just don't see why you'd want to.
@Simon Can you suggest a non-web python framework?
Before I could answer that I would need to know what you need it for.
00:00 - 18:0018:00 - 00:00

« first day (2623 days earlier)      last day (2550 days later) »