« first day (1964 days earlier)      last day (1281 days later) » 

9:24 AM
someone was busy...
 
 
3 hours later…
12:24 PM
@AndrasDeak yayy....
Just had a fun little exercise in reverse engineering: electronics.stackexchange.com/a/532450/103406
 
@flawr very nice!
 
 
2 hours later…
2:06 PM
@AndrasDeak hey there, you here?
 
at the moment, yes :)
might have to leave any time
 
quick python plotting question: suppose I have a boolean vector and I want to color the background of the plot either red or green depending on the value, how would I approach this?
so basically plotting a collection of rectangular patches/polygons
 
Assuming you mean matplotlib, the only thing that comes to mind is using ax.axvspan(from_val, to_val, color=...) for each contiguous island of True/False
so you'd first have to find the switching indices with np.diff, probably
Or color everything to one colour and then paint the rest (only True or only False) regions but my hunch is that this would be more work than alternating spans
 
np.diff returns the vector the same length as the input, huh?
 
Give or take 1. But I meant something like np.diff(arr).nonzero()[0] to get switching indices
and then prepend 0, append the last index, and then iterate a 2-length moving window of this array
 
2:12 PM
ok, I'll try that. Thanks for the tip!
 
no problem
from itertools import cycle

for from_val, to_val, color in zip(bound_vals[:-1], bound_vals[1:], cycle(['red', 'green']));
    ax.axspan(from_val, to_val, color=color)
I'd do the rest like that ^
there's probably some room for off-by-one errors with np.diff
@AndrasDeak s/axspan/axvspan/
 
roger that
 
there was also a missing step to index your data with the bound indices, but that probably goes without saying :)
 
2:28 PM
yeah, did that
 
 
2 hours later…
4:23 PM
Happy Diwali
 
 
5 hours later…
9:05 PM
Happy Sigd
 

« first day (1964 days earlier)      last day (1281 days later) »