Closed taldcroft closed 1 year ago
For the aca_weekly_report, I think technically it would need to change to match current code behavior, but I can't see that it matters for that reporting.
With regard to your question @javierggt , "Isn't intervals["val"][-1] always True in here? In other words: the last interval is always dropped?" I'm not clear on that. For state_intervals, when that second argument is bools, the intervals are going to end up as a table of all the intervals but annotated such that "val" is True or False based on it if that row matched the condition. So I figured if we are in the non-matching state at the end, intervals["val"][-1] is false.
Demonstrating what @jeanconn said with code, the final True
interval is not always dropped.
In [15]: times = np.arange(100, 105)
In [18]: vals = np.array([1, 0, 1, 0, 0], dtype=bool)
In [19]: logical_intervals(times, vals, complete_intervals=True)
Out[19]:
<Table length=1>
datestart datestop duration tstart tstop
str21 str21 float64 float64 float64
--------------------- --------------------- -------- ------- -------
1998:001:00:00:38.316 1998:001:00:00:39.316 1.0 101.5 102.5
Description
The utility function
cheta.utils.logical_intervals()
has a poor choice of default withcomplete_intervals=True
, with only myself to blame. This means that anyTrue
intervals that extend to the start or stop of interval are dropped. This behavior is good and necessary in certain situations (like kadi events where you don't want to store partial/incomplete events), but most of the time you expect to get all the intervals within the data.This default setting cost me a couple hours debugging in https://github.com/sot/kadi/pull/261 finding an issue that depended oddly on the start / stop times.
Interface impacts
This changes a default that may impact code. For the most part I would expect that this will fix latent bugs where the code is actually assuming
complete_intervals=False
, but we'll need to advertise this.Impacts to code in the
sot
repository.I have a directory that has a clone of every
sot
repository, and did the following audit to identify aTesting
Unit tests
Independent check of unit tests by Jean
Functional tests
No functional testing.