« first day (4883 days earlier)      last day (290 days later) » 

00:13
Tried with the following code for clustering
import matplotlib.pyplot as plt

plt.plot(range(1,11), inertias, marker='o')
plt.title('Elbow method')
plt.xlabel('Number of clusters')
plt.ylabel('Inertia')
plt.show()
It throws error saying ValueError: x and y must have same first dimension, but have shapes (10,) and (20,)
 
6 hours later…
06:32
Is it common to have someone who is considered "senior" constantly question your code, with questions that are just silly?
ie I have : merged_dict = dict1 | dict2 and senior is halting my PR with "are you sure dict1 isn't being overwritten now? "oh and btw, why did you pass None as default parameter for dict1, instead of setting it directly to {} in the function header.
I feel terrible telling him "that's just how python works, why do you ask these things you're supposed to know them as the more senior position".
The world is full of incompetents, sadly
Just have to think of a way to not sound condescending or passive aggressive. I might just suck it up and rewrite it to not use mergers even though it will make the code look ugly
 
2 hours later…
08:47
@paul23 I recommend a succinct and neutral response, possibly referencing the docs. Something like 'Yes, according to the specification this will "Create a new dictionary with the merged keys and values [...]" without modifying either operand.'
 
2 hours later…
10:35
are they supposed to be a senior python dev? because if not, those are completely valid questions. either way, 99 out of a 100 times it's a good idea to be patient and cordial. in my experience, once basic hard skills are met, soft skills are the more deciding factor for advancing your career.
so you can take this as a training exercise =)
10:47
I've got an algorithm and am trying to figure out just what exactly it is canonically called. Personally I would describe it as "window sort" but Google disagrees. It slides over a stream in a window and always emits the lowest value so that almost-sorted streams get sorted.
def window_sort(stream: 'Iterable[T]', n: int) -> 'Iterable[T]':
    itr = iter(stream)
    return heapq.merge(*[itr]*n)
^ Simplified implementation. list(window_sort([1, 3, 2, 4, 5, 7, 6, 8], 5)) => [1, 2, 3, 4, 5, 6, 7, 8] and list(window_sort(range(10)[::-1], 5)) => [5, 4, 3, 2, 1, 0, 6, 7, 8, 9]
 
3 hours later…
13:31
Somebody knows how these CI things work? github.com/ros2/rcutils/pull/441#issuecomment-1966814917 I tried to comment CI to start a run but it didn't work. Is there a bot which starts it for users with specific rights or is there another way to start it and this just links to the results?
Are you sure they don't just adjust the markdown manually? Updating the links for three badges isn't that much volume.
@Arne Sooooo true, hard skills are a given, the decider is soft skills
@MisterMiyagi I don't know could be, I was wondering how it works
The (GitHub) nots that I know all need an @mention to trigger.
*bots, not nots...
I see
 
2 hours later…
15:20
Tapermonkey is such a valuable tool. We have a tool at work which has a large woman as the background to the login screen and she looks very creepy, with it I can just block her :)
There are specialized addons for injecting CSS like Tampermonkey injects JS. Stylish, Stylus, etc
15:46
@Aran-Fey that sounds quite nice, gotta try them once. Weren't you also the person who recommended me tapermonkey?
Possible, but I don't remember
I have to say, sometimes it's annoying that python is a slow language. I just had to google how to check if all numbers in a pandas series are integers. In a fast language, pandas wouldn't have had to reinvent all the wheels
16:11
Did you not use something like this?
I suppose if you didn't want it in-place then you would have to use a copy to make a sacrificial column for your mask, but it doesn't look too onerous
I actually ended up writing a plain ol' all(...) with a generator expression
oof, the numpy method would be much faster, especially since a Series maps directly to the underlying numpy array
There are other numpy methods discussed in this thread but it looks like there are already methods that don't rely on mod and they seem to really just be talking about friendlier naming for their purpose in this case
Hmm. I think my generator expression will generally fail faster, but most data sets will probably pass
It annoys me that numpy would iterate over the whole list 4 times
calculate condition 1, calculate condition 2, and the two, then check for Trues
(The actual code is all(n.is_integer() and n >= 1 for n in values))
Are you sure of that? I know np.where() would have to do that, but I'm not sure about a specialist mask in this case
Ah, I didn't realise you had two conditions
I like to omit information that later turns out to be relevant :)
16:24
I think you could probably collapse that into a single masking pass for both conditions
Hmm, maybe not
"and the two, then check for Trues" assuming you mean "add" then wouldn't you just multiply them into a condition that's either 1 if both True or 0 otherwise?
So you could get it down to three
You could do a single pass if you wanted to fail fast too - just do a mask of arr = arr[arr >= 1] and check the length against the original. Bail if it's different
Doesn't that have to loop over the array twice? Once to compute arr >= 1 and then to apply the mask?
Ah, true. .all() won't help you either.
Thank god computers are fast, because the code we write is hilariously inefficient
I bet pythran or numba could compile out the second pass. I won't be satisfied until you've thrown the kitchen sink at getting that extra loop out
(actually, on a slightly more serious note, you could just write the single pass yourself in a function using regular python, throw a @njit decorator on it and it'll outperform numpy)
I mean, the speed isn't actually a problem. It just makes me facepalm when I think about all the stuff that happens under the hood
16:39
Yeah, I'm deliberately labouring the point :) But if you did care about speed in one particular part, numba is just ridiculously simple
Nov 30, 2023 at 7:16, by roganjosh
I don't think I'll ever stop being impressed at just how heavy duty numba is for ridiculously lightweight syntax. 27 mins -> 2.7 seconds with 1 import and a decorator (and, ok, a slight refactoring in the bottom half of the answer to cache intermediate calculations).
The good thing about numba is that it only has one-time overhead. But I'd still have to facepalm at the fact that it parses and transpiles code at runtime
... tough crowd :P
True that
I'm honestly a bit surprised that python programs don't take longer to start up. There's got to be like a bajillion file system accesses due to imports, followed by dynamic code generation if you use numba or dataclasses or something of the sort
I'm not sure numba has anything to do with CPython? I've never really looked at its internals
I'm not too familiar with it either, but it has to parse a python function and compile it to native code, right?
16:48
I thought it worked more like kernprof just lurking in the background watching what goes on. Though, if you choose not to cache the compiled code, I guess it somehow has to link its compiled code into the runtime
Once it's cached, CPython would just link it I guess on the next run
<hand waving frantically>
Oh, it can cache the compiled code? Welp, that's smart
Yeah, you only have to JIT once if you really wanted, otherwise you just dump it to file for subsequent runs. I'm surprised I don't see it more often when you see questions/answers about it on SO. I mean, why wouldn't you do that unless you're running on a tamagotchi?
17:25
@smci Ex Machina died this morning. Pro Machina was born weighing a whopping £167 and 49 pence. I spent days trying to come up with a new name but ran out of time - I need to get all the brand stuff sorted. Still, I think it's more positive on every count (no pleasure-bots), "ex" (a negative word) goes to "pro" and, crucially, all the domain names were available (except for www.pro-machine.com that someone is squatting, but I'm not bartering to cover for a typo!)
 
2 hours later…
19:13
I wish mathematicians had a builtin static type checker for their formulas. "Next, calculate the expected value of the mean." Excuse me, what? Calculate the expected value... of a value? How did this gibberish make it into a wikipedia article?
7.2
But you could try predict an expected value of a mean. Back to the horrible school examples of drawing marbles from a bag. You have a handful of marbles, each colour assigned a value, and you know the total number of marbles overall. You therefore know the existing mean, and the probability of drawing each of the different colours, so you could estimate what impact drawing a new marble would have on the new mean
I don't know what you're reading, but I'm betting 1.5 Quatloos on "Bayesian" being in the article
Your silence only indicates to me that you're furiously editing it out to win
19:28
It was something about calculating the unbiased weighted variance
I'm too annoyed to dig it up again

« first day (4883 days earlier)      last day (290 days later) »