« first day (2135 days earlier)      last day (1100 days later) » 

8:08 AM
@CrisLuengo That's not how this works D:
 
 
4 hours later…
11:58 AM
@AndrasDeak this might be a case for you stackoverflow.com/questions/67400470/…
 
hmm, yeah
 
sounds like some unravel/ravel wizardery is needed
 
12:17 PM
done
 
that's more elegant than I expected
 
Don't nerd snipe me like that :P
 
Well it worked and OP as well as I got an answer, so I consider that a win-win:P
 
12:37 PM
Good MCVE from OP by the way
 
I only do high-quality-nerd-snipes
no I actually thougth the question was well written so I actually gave it some thought:)
they are rare enough
 
I tend to upvote those, even if they are easy of have a common misconcepcion
props for the well write question must be given!
easy mistake, but is a perfect example of a good question
 
I have a small python question... So I'm trying to have indexing with a logical condition (so basically arr[0:-(condition)] ). My issue is with the inclusive:exclusive indexing, where if the input array is of length 1, I'm getting an empty output regardless of the condition (in such a case the end index should be empty)
What can I do if I want to keep this branchless?
 
Do you have a more specific example for the two branches?
 
12:54 PM
I'm trying to determine whether the last row in a 2d array contains values that are smaller than a particular threshold, if the values are smaller, the row should be deleted and not otherwise
For convenience I'm checking only 1 value
Premature optimization?
 
Where's the branch?
 
I only need to do this for the last row
If last row has small values, delete it, otherwise don't
 
OK, but I don't get the actual problem
@Dev-iL so why not just an if?
 
Allergy to if
 
Oh, yeah, absolutely premature
Readable code first
if cond:
    arr = arr[:-1, :]
 
1:05 PM
arr[:-1 if cond else None, :]
:)
or arr[:(None, -1)[cond], :]
 
nono first of those, second is ununununreadable
 
thats a four fold negation which means no negation
I'm glad you agree
 
ಠ_ಠ
 
@flawr ooh, shiny
 
@Dev-iL spoiler alert: it still has an if in there:P
 
1:26 PM
@Dev-iL ^
Only the last one is branch-free, and it's terrible
And python is so heavy that branches are free
 
 
1 hour later…
2:34 PM
(btw, thanks for the help)
 
Anytime :)
 

« first day (2135 days earlier)      last day (1100 days later) »