Public Member Functions | |
| def | __getitem__ |
| def | __getslice__ |
| def | count |
| def | density |
| def | segmentlist |
| def | add_ratebin |
| def | find |
| def | density_at |
| def | __iand__ |
| def | __ior__ |
| def | __isub__ |
| def | __invert__ |
| def | coalesce |
| def | from_xml |
| def | to_xml |
Modified version of the segmentlist type (see ligo.segments) whose arithmetic operations implement the segment-and-count arithmetic operations defined by the ratebin type. This implemention has only been optimized for performance for the specific use cases for which it has been designed. It will likely be found to have unacceptable performance if used as a general-purpose segmentlist implementation. Example: >>> x0 = ratebinlist([ratebin(0, 10, count = 5)]) >>> x1 = ratebinlist([ratebin(5, 15, count = 2.5)]) >>> x2 = ratebinlist([ratebin(15, 25, count = 2.5)]) >>> x3 = ratebinlist([ratebin(20, 30, count = 5)]) >>> x0 | x1 [7.5@[0,15)] >>> x0 | x1 | x2 | x3 [15@[0,30)] >>> x0 - x1 [3.75@[0,5)] >>> x0 | x2 [5@[0,10), 2.5@[15,25)] >>> (x0 | x2).density 0.375 >>> x0 - x1 [3.75@[0,5)] >>> x0.density 0.5 >>> (x0 - x1).density 0.75 >>> x0 - x2 [5@[0,10)] >>> y = ratebinlist(x0) >>> y.extend(x1) >>> y.extend(x2) >>> y.extend(x3) >>> y [5@[0,10), 2.5@[5,15), 2.5@[15,25), 5@[20,30)] >>> y.coalesce() [15@[0,30)] >>> # slices are ratebinlist objects >>> (x0 | x3)[1:].density 0.5 >>> # density is 0 at times with no segments >>> x0.density_at(15) 0.0 >>> # and empty lists have a mean density of 0 (not NaN) >>> (x0 & x2).density 0.0 NOTE: the XML I/O feature of this class will only work correctly for float-valued boundaries and integer counts.
Definition at line 218 of file trigger_rate.py.
| def stats.trigger_rate.ratebinlist.add_ratebin | ( | self, | |
| seg, | |||
| count | |||
| ) |
Convenience method. Equivalent to self |= type(self)([ratebin(seg, count = count)]) Example: >>> x = ratebinlist() >>> x.add_ratebin((0, 10), 5) >>> x.add_ratebin((10, 20), 5) >>> x [10@[0,20)]
Definition at line 303 of file trigger_rate.py.
| def stats.trigger_rate.ratebinlist.coalesce | ( | self | ) |
Sort the elements of the list into ascending order, and merge continuous segments into single segments. Segmentlist is modified in place. This operation is O(n log n).
Definition at line 471 of file trigger_rate.py.
| def stats.trigger_rate.ratebinlist.find | ( | self, | |
| item | |||
| ) |
Return the smallest i such that i is the index of an
element that wholly contains item. Raises ValueError if no
such element exists.
NOTE: unlike the segmentlist class from which ratebinlist
is derived, this implementation requires the ratebinlist to
be coalesced.
Example:
>>> x = ratebinlist([ratebin(0, 10, count = 5), ratebin(15, 25, count = 2.5)])
>>> x.find(-1)
Traceback (most recent call last):
...
IndexError: -1
>>> x.find(0)
0
>>> x.find(5)
0
>>> # upper bounds of segments not included in span
>>> x.find(10)
Traceback (most recent call last):
...
IndexError: 10
>>> x.find(12)
Traceback (most recent call last):
...
IndexError: 12
>>> x.find(15)
1
>>> x.find(20)
1
>>> x.find(26)
Traceback (most recent call last):
...
IndexError: 26
Definition at line 330 of file trigger_rate.py.
| def stats.trigger_rate.ratebinlist.segmentlist | ( | self | ) |
Construct and return a segments.segmentlist of segments.segment objects by type-casting the contents.
Definition at line 296 of file trigger_rate.py.
1.8.5