« first day (2973 days earlier)      last day (2200 days later) » 
04:00 - 19:0019:00 - 00:00

wim
wim
19:04
yeah, yours is probably faster. timing now ...
Differences are that I broadcast instead of meshgrid and bincount instead of that comprehension. However, that comprehension takes care of edges at the same time so without it, you'd have to account for masking with an np.in1d which shouldn't be too expensive.
wim
wim
dang, these .ipynb files are annoying. isn't there any way to just get a plain old source file from that mess?
I think you can export into python from jupyter at least...
github probably doesn't do that
Also, I need volunteers to join this leader board. I don't need many 376145-a1200691
n8_
n8_
@coldspeed, I added a comment to your answer from my post from yesterday. If you have time, can you check it out?
19:07
without the headings ipython might even be able to parse the pretty version
ah, no
n8_
n8_
@coldspeed, you're the best!
wim
wim
joined
it should also be inside a function
wim
wim
who's ben jacobson
He is the son of our CFO
19:08
@n8_ sure, no problem and done
That board was me trying to get folks at work to join. No one did. But one guy sent code to his son (-:
wim
wim
haha
what, you guys don't want more work in your free time?! madness
ouch, Eric awards no leaderboard points for day 6 because of the bug. I guess it was a good day to arrive late!
Again, I take on the mantle of Python expert among a company of ~20 people. I'm trying to get folks more comfortable with python. Encouraging them to take risks, like the risk of not looking like you are awesome at everything.
No. It says only for global leader board
@wim fair enough
n8_
n8_
ok @coldspeed, one more question. This solution only finds the first column that startswith AgeAt, but my file has multiple columns in the same file that start with AgeAt. Other than hardcoding each as the entire column name, is there a workaround?
wim
wim
19:21
import requests
from types import ModuleType

url = "https://raw.githubusercontent.com/pirsquared/Advent-of-Code/master/2018/Day06.ipynb"
cells = requests.get(url).json()["cells"]
source = '\n'.join([line for cell in cells for line in cell["source"]])
mod = ModuleType("Day06")
exec(source, mod.__dict__)
print(mod.c.max())
wim
wim
crazy. what a gross format.
@n8_ remove ".iloc[:, 0]" from the first solution, or [0] from the second
lunch rbrb
that returns every column, not just the first
19:27
Eh? Can't delvote anything there
n8_
n8_
hmm, so when I replace [0] with ] (to close it) it does return the negatives values, but it also returns all columns and their values between
So if col B has negs, and Col D does too, it returns columns C but no other columns
wait, that may be wrong...but when I remove [0] completely, the next line " negAge = df[df[age_df] < 0]" gives a syntax error
I meant to say, it returns col b, c and d
but no others
wim
wim
yes we can, we just have to downvote it 38 times first.
I'd rather we didn't. See also meta.stackoverflow.com/questions/307009/…
Try flagging for a mod. The self-edited strikeout should be a good start to convince them.
wim
wim
unrelated. that's the retagging zombies.
outdated answers that are bad and can't be edited into shape should be downvoted and eventually deleted.
Not unrelated. Different issue, similar problem.
either way we won't start having downvote-pls sessions here
will you mod flag it?
19:36
@n8_ Okay, I am getting confused. Can you please open a new question?
wim
wim
In my experience high rep users actually want their bad accepted answers unaccepted and/or deleted.
n8_
n8_
sure, sorry for the confusion and thanks for all your help so far
I think that's the best thing to do here. Without access to your data, nothing can be said definitely.
sure
wim
wim
since there is no feature to give away the accept to the better answer
some evidence
@wim no :) I am really willing to remove this answer. Hope it happens during the winter bash and there is a secret hat related to that :D — alecxe 17 hours ago
I'm not saying we shouldn't delete it. I'm saying it shouldn't cost 200 rep to the answerer
Downvoting it into oblivion is a workaround due to the system being broken. That doesn't justify doing that.
Heck, they would be better off by 6 spam flags nuking the answer and giving the answerer instant -100 rep. Would that make it even better in your opinion?
faster and less rep penalty, what could go wrong?
19:40
I am trying to list out all the possible combinations of groups of 3 that one can make of 6 people. (A,B,C,D,E,F)

- The order doesn't of the group doesn't matter
- The order of the pair doesn't matter

Possible combinations:
    {(B→D),(C→E),(G→H)}
	{(B→C),(D→E),(G→H)}
	{(B→E),(C→D),(G→H)}

I could only get as far to write:

from itertools import combinations
x = combinations('ABCDEF', 2)
z = [y for y in x]

I have no idea on how I should create combinations out of combinations, the docs is not to much help.
wim
wim
no. it's not spam.
(just to be clear, I'm being sarcastic)
wim
wim
it's bad/outdated content. bad/outdated content should be downvoted, and it should cost rep.
wim
wim
what is 200 rep to a user on 10k anyway, it's nothing.
19:40
As you said, we'll just disagree again
wim
wim
the point of voting is to make sure content on site is good and relevant and current and stays that way. it's not to hurt someones feelings or punish them.
Of course not.
will this quality for roomba? If not, stackoverflow.com/q/53658434/4909087, TIA
wim
wim
@coldspeed you don't have the plugin?
search roomba forecaster on meta
I thought it's on stackapps
19:44
nice! let me check this out
wim
wim
eh I forget where I got it.
I don't know much about all the good things people use to make their lives easier. I JUST recently learned I can sub to RSS feeds for my favourite topics.
wim
wim
@AndrasDeak maybe when you have been here another 4 years you will agree :)
I doubt it
which is to say, I disagree
wim
wim
>>> timeit Day06.foo(data)
175 ms ± 5.57 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
>>> timeit q06.part_ab(data)
392 ms ± 14.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
@piRSquared you are more than twice as fast!
19:52
Cbg
wim
wim
I didn't include the 10 minutes it took me to actually get your code into a re-usable state, LOL.
wim
wim
link?
edited
wim
wim
ooh, scipy spatial
19:55
Yeah I saw that and thought, "Nah. Brute force."
from a preliminary test it should time similar to piR's
hmm, no, probably slower
either way this is the first one I'm happy with
wim
wim
errr yours crashes
oh, right, sorry
it expects a split-on-newline list as input
wim
wim
>>> !pip install scipy > /dev/null
>>> import andras
>>> from aocd import data
>>> timeit andras.day06(data)
ValueError: invalid literal for int() with base 10: ''
ah ok
>>> data = data.splitlines()
>>> timeit andras.day06(data)
101 ms ± 709 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
ooooh, neat
wim
wim
19:58
🥇
\o/
makes up for the 40 minutes I spent writing it :D
wim
wim
cdist is manhattan?
Among other things.
the 'cityblock' method is
default is Euclidean of course
wim
wim
gotta remember that
when I googled I only found this piece of crap: cityblock
I see. Yeah, I started from the docs of cdist directly
wim
wim
20:04
tieds is not a real word
you should see my other codes
cvecses = [[ ... ]] # list of list of  lists, each list a list of cvecs
for cvecs in cvecses:
    function_with_cvec_inputs(*cvecs)
Advent of Bad Naming Conventions?
stuff like that ^
wim
wim
NameError: name 'cvecses' is not pronounceable
Gollum has no trouble saying stuff like that
20:06
nasty little cvecses
wim
wim
heh
exactly :P
wim
wim
your reshape the meshgrid is a good trick too
thanks
wim
wim
slip that in the ol' toolbelt
20:09
hellllooo
cbg
one of the reasons why I prefer not to use meshgrid (but rather mgrid)
wim
wim
I used mgrid too but I didn't know that crazy transpose trick
n8_
n8_
thanks again for all your help and assistance @coldspeed. Here is my new post if you are interested stackoverflow.com/questions/53659027/…
wim
wim
think anyone would be interested in a webpage to benchmark the solutions? the requirement would be that your code runs in a function which accepts the raw data as argument, I could automate the rest.
there's probably endless interest in nerding around AoC
wim
wim
20:21
(the issue being that benchmarks have to use same input data)
though I'm not a huge fan of extreme competition, performance is a nontrivial aspect of AoC (where the default is trying to hammer together something as quick as possible first) which might be interesting
wim
wim
wow, Martijn is writing them up like lecture notes. good stuff!.
I'm content as long as my program finishes executing in under 24 hours
@wim Voro-noice!
wim
wim
20:39
wow firefox is virtually dead browser share
how come is it behind edge and IE
perhaps all the firefox users opted out from tracking so they aren't visible as firefox users :P
Lately I'm mad at FF because every time I bookmark something it puts it in the "other bookmarks" folder by default instead of in my bookmarks menu. When it first started happening, it took me a couple days to understand that my bookmarks weren't vanishing entirely, but being stored in a folder that's only accessible by opening a new window. Dumb.
can't that be changed?
‾\_(ツ)_/‾
Possibly support.mozilla.org/en-US/questions/1195435 contains the solution to my quandary. Let's discover it together.
20:47
hmm, not trivially
yup, an add-on
:-I
at least ctrl+b will toggle the bookmarks tab, so not exactly a new window
@wim I've flagged my own accepted answer and it was taken care of promptly
Anyway. This one bug is probably why their market share tanked, I'm sure.
wim
wim
don't know why so many people use safari, it's garbage compared to chrome
suspect it's because when you click a link on a text message for an iPhone apple opens that in safari and apparently doesn't offer you any way to change the default browser to chrome
they pull the same dirty trick with apple maps and addresses 👿
20:55
@coldspeed what is going on in that question lol. You just offered some (correct) advice and got the guys resume :P
I wonder if I'm about to get into hot water by telling this user that it's not worth the effort to ensure that your code isn't byte-for-byte identical to an existing solution
There are only so many ways to write FizzBuzz
@user3483203 At least I can forgive the downvote, the answer wasn't actually correct, and I didn't realise until they pointed it out. But the fix was trivial anyway. Not worth a dv, but that's just me.
I'm more confused by the long winded responses about high performance pandas usage. I can't recall a time I've ever found apply to be faster than even a list comprehension or python for loop
pro-tip: use np.vectorize (don't)
^ but it's vectorized! It's in the name.
/opens cage to corral of pet peeves and lets out the one named 'vectorize'
IMO, all things are loops. Vectorized should only truly apply to things in which an algorithm applied to a vector improves time complexity. I can stomach the application of the term when it means the use of libraries that are a lot faster.
21:06
@user3483203 yes, and it's something I've learned is not worth getting into. I think I bruised their ego more than anything else by saying their code was slower than the other answers.
This will always be one of my favorite XKCD's
Hits a little too close to home sometimes :P
I haven't seen that one. It's awesome
added timings :D
@coldspeed do you mind if I update your timings with something a bit more randomized?
Adding more groups shows the real downside of non vectorized solutions
yes, please (no, I don't mind at all)
Also, a random pro-tip: If you search for the [python*] tag (note the asterisk), it'll return questions with every possible python subtag ever.
Cheers, edit looks great
21:20
I decided against doing 10_000 groups, but it takes apply like 12 seconds on my machine compared to 20ms for yours
I sort of understand saying apply is not terrible for vectorized operations inside the lambda on large data frames with very few groups, but to not admit the scaling is awful is just wrong
welp, that's my quota of "politely disagreeing with people on the internet" met for the day
@wim What else to use though? Argparse?
wim
wim
16 freaking decorators on an rq worker. By the time it's done with the function, it's now some <click.core.Command at 0xdeadbeef> thing with a completely different signature.
I don't care, parse sys.argv manually if you want. Just don't couple the CLI to the library code, it's really developer-unfriendly.
Ah, so it's more about usage than the library itself
> don't couple the CLI to the library code
hear hear
wim
wim
I want to get in first and register some signals, but click has put 10 layers of magic in between which is almost impossible to untangle
@piRSquared Flash Flood warnings... take care!
21:58
yikes
Must be contagious, near me as well. It's already been crazy with the Bush funeral
I should be good. My commute is Irvine to San Diego daily
22:09
@wim click doesn't force you to do that, though. People just don't bother making a separate function that they can decorate.
Considering that that function is defined in a file with the name cli.py, I don't think there's actually anything wrong with that
I'm about to accept my own answer here but I don't really like it. I would have deleted it tbh but it got a favourite so I assumed there was some interest in an approach. The question looks a bit big so maybe put people off but half of it is just copy/paste so you can see a demo locally for the random swaps.
So if anyone has something more elegant in pandas and wishes to have a pop, I'm open to accepting a different answer :)
well you can always wait with the accept hoping that whoever favourited it will get back to it on the weekend
This is true I guess
I shot myself in the foot a bit by using pandas cos the reality is that the heuristic runs in numpy but it made a demo much easier, but also made me feel I should close with an answer using pandas
Thankfully I only have to use the method to generate the indices once so the efficiency isn't really an issue for me, but I could envisage needing to do something pandas repeatedly
22:24
I don't really understand your question, to be honest
and you can use [100]*8 instead of listcomps ;)
What part is unclear? Happy to clarify if that's the blockage to others answering
well, for starters I don't see what the input is, what the output is, and what the objective is
but I'm quite tired and it's half past 11 here so perhaps it's just me
The heuristic is simulated annealing. Randomly swap a 4 hour block of production to a different product and run the cost function. Is it a better schedule for meeting production targets? It's fine when all machines run on the same shift. Once you throw lots of shift patterns into a single problem, it's not so easy to ensure that some machines don't end up stuck with a product that never changes through all iterations
That's my problem: what cost function? What production targets?
That's not relevant
22:28
oh?
It's just for context. The point is that some machines would just get stuck with a single product in a slot
And the heuristic would never have the opportunity to change production in that slot. How I evaluate the cost is not relevant.
OK? I'm afraid it just doesn't click for me
If you were playing a game of tic-tac-toe and your algorithm could never change the value in the central square... that's an issue
Yeah, but unless I know the rules of tic-tac-toe I'm free to rearrange the symbols as I see fit
Algorithmically :P
22:32
algorithmically I pick up all the pieces and put them down again
I have no idea what constraints your dataframes have during rearrangements. Without that it's just arbitrary rewriting of rows to me
Aha ok
if it's written in your question then it's fine
all I could find after two reads is a collection of arbitrary dataframes and code that "works" or doesn't
Couple of points: 1) if you had a 6-2 shift, then 16 indices would be pointless to swap
1) makes no sense to me so you might as well just stop
what's a 6-2 shift?
Ok
6am to 2pm
22:34
OK
what is "16 indices"?
Each index representing an hour of the day
OK. What do you mean by "16 indices would be pointless to swap"?
what does even "swap" mean in your problem?
so your "production" column is fixed, and you want to change the rows of the "product" column?
This reminds me of an interview question I was asked by some manufacturing company
Did you run the first, self-contained code block in my question?
I ran the second, not the first, hold on
22:37
That illustrates exactly what I'm talking about
now I did
Run it a few times
You'll see that the machine is assigned a different product in a 4 hour block
done
so far so good :P
So, you start with the machine making 800 of product a, then make a swap so it now makes 400 a and 400 b
22:39
That can be evaluated against your production targets for the day in a cost function (the exact details of which are not relevant)
if you have 8 contiguous slots and want to change in blocks of 4 there's nothing else you can do, can you?
Now, in the context of the second example, there is a 4 hour block of production that can never be assigned to another product
questions that require less than 10 characters of a fix really shouldn't be questions here
And that was my issue
@coldspeed unless it's a typo
in which case it shouldn't be a question here for long
@roganjosh why not? Or is your problem the heuristic?
because in that case you can just introduce a rotation or random shuffling of the products, globally
yup, unnecessary dupe
already done
Because you don't want to swap production for every single hour of the year. Add to that that if the machines aren't even running, it's pointless to assign production to them during those hours. Your problem would never converge in any reasonable time
@roganjosh I'm not sure I understand. I meant taking a given configuration you have with "stuck" product B, and replacing A -> C -> B -> A, so you'd end up in a new state where the isolated block has A
The point is to target the swaps as blocks of actual production
The reason your block is "stuck" is that the corresponding contiguous block is too small compared to your "minimal working hours" size. So you'll always have a single kind of product there, regardless of heuristic
22:47
Exactly. But with a mix of shifts, it's not so easy to do that and still get flexibility. Some machines work 24 hours for 4 days, then 12. You can't take entire blocks
OK. I have too little domain knowledge and mental stamina left to be of help :)
You have to balance flexibility in the schedule with the potential usefulness of the swap
We'll move on :) I only added a little context, had hoped the expected output was more independent of the detail
from a simulated annealing point of view I'd expect these finnicky details to be partly in the cost function and partly in the transition probability from one state into the next
rbrb all!
23:01
@AndrasDeak absolutely not. SA is nothing more than an acceptance function at the end of the day. How you generate solutions is your own concern
Note, this is way beyond anything to do with my question. I'm absolutely more than happy to keep discussing if you're curious but just note that it's not related to my question :P
nah, it's fine, thanks :D
Your loss :P
I'm quite amazed I managed to partially maintain that convo on a phone whilst walking and managed to make it back without dog poop on my shoe. Out here it's hard enough to do that in daylight whilst semi attentive. Today is a good day.
wim
wim
23:16
Run the sample code and verify whether that works or not. It works on my system. — SilentGuy 34 mins ago
is this guy bluffing ?
unless I have fundamental misunderstanding about pytest, what he's claiming is just impossible
@wim does autouse=True make it work the way he claims?
wim
wim
hell no
It makes sure the fixture is entered, but it doesn't randomly chuck it into any/every local namespace, that would be horrible
yah...I just tried it and got TypeError: 'function' object is not subscriptable.
@wim better yet...in global namespace...oh wait, that name is already defined globallly.
wim
wim
yes otherwise you would get NameError not TypeError
@roganjosh where are you that people don't pick up after their dogs? I had the same problem when I lived in Paris .. la merde du chien partout
Ça m'énerve!!
23:36
la yamme du chien partout, you mean
@wim I'm in a place called New Mills in Derbyshire. It's out in the hills and every man and his dog (hmmm)... has a dog
people picking up after their dogs is getting more frequent here, but still not very typical
The worst are people who pick it up and put it in a bag and then either throw it into a tree or just dump it on the floor. That kinda logic short-circuits my brain
ech, yeah
"must preserve this poo for centuries to come"
rhubarb
To be fair, dino poop isn't cheap. Maybe they have an investment strategy we don't see
Rbrb Andras
23:59
how do I put the contents of a qfile into a qbytearray or a string?
04:00 - 19:0019:00 - 00:00

« first day (2973 days earlier)      last day (2200 days later) »