Package glue :: Package ligolw :: Module lsctables :: Class Segment
[hide private]
[frames] | no frames]

Class Segment

source code

         object --+    
                  |    
table.Table.RowType --+
                      |
                     Segment
Known Subclasses:

Example:

>>> x = Segment()
>>> x.start = LIGOTimeGPS(0)
>>> x.end = LIGOTimeGPS(10)
>>> x.segment
segment(LIGOTimeGPS(0, 0), LIGOTimeGPS(10, 0))
>>> x.segment = None
>>> print(x.segment)
None
>>> print(x.start)
None
>>> # non-LIGOTimeGPS times are converted to LIGOTimeGPS
>>> x.segment = (20, 30.125)
>>> x.end
LIGOTimeGPS(30, 125000000)
>>> # initialization from a tuple or with arguments
>>> Segment((20, 30)).segment
segment(LIGOTimeGPS(20, 0), LIGOTimeGPS(30, 0))
>>> Segment(20, 30).segment
segment(LIGOTimeGPS(20, 0), LIGOTimeGPS(30, 0))
>>> # use as a segment object in segmentlist operations
>>> from glue import segments
>>> x = segments.segmentlist([Segment(0, 10), Segment(20, 30)])
>>> abs(x)
LIGOTimeGPS(20, 0)
>>> y = segments.segmentlist([Segment(5, 15), Segment(25, 35)])
>>> abs(x & y)
LIGOTimeGPS(10, 0)
>>> abs(x | y)
LIGOTimeGPS(30, 0)
>>> 8.0 in x
True
>>> 12 in x
False
>>> Segment(2, 3) in x
True
>>> Segment(2, 12) in x
False
>>> segments.segment(2, 3) in x
True
>>> segments.segment(2, 12) in x
False
>>> # make sure results are segment table row objects
>>> segments.segmentlist(map(Segment, x & y))   # doctest: +ELLIPSIS
[<glue.ligolw.lsctables.Segment object at 0x...>, <glue.ligolw.lsctables.Segment object at 0x...>]

This implementation uses a non-standard extension to encode infinite values for boundaries: the second and nanosecond components are both set to 0x7FFFFFFF or 0xFFFFFFFF to indicate positive resp. negative infinity. For this reason, "denormalized" LIGOTimeGPS objects (objects whose nanoseconds fields contain values exceeding +/-999999999) are disallowed for use with this class.

Example:

>>> x = Segment()
>>> # OK
>>> x.start = -segments.infinity()
>>> # also OK
>>> x.start = float("-inf")
>>> # infinite boundaries always returned as segments.infinity
>>> # instances
>>> x.start
-infinity
>>> x.end = float("+inf")
>>> x.segment
segment(-infinity, infinity)
Instance Methods [hide private]
 
__abs__(self) source code
 
__cmp__(self, other) source code
 
__contains__(self, other) source code
 
__getitem__(self, i) source code
 
__init__(self, *args)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__len__(self) source code
 
__nonzero__(self) source code
 
get(self)
Return the segment described by this row.
source code
 
set(self, segment)
Set the segment described by this row.
source code

Inherited from table.Table.RowType: __getstate__, __setstate__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  end = <glue.ligolw.lsctables.gpsproperty object at 0x7f390418f...
  segment = <glue.ligolw.lsctables.segmentproperty object at 0x7...
  start = <glue.ligolw.lsctables.gpsproperty object at 0x7f39041...
Properties [hide private]
  creator_db
  end_time
  end_time_ns
  process_id
  segment_def_cdb
  segment_def_id
  segment_id
  start_time
  start_time_ns

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

Class Variable Details [hide private]

end

Value:
<glue.ligolw.lsctables.gpsproperty object at 0x7f390418fb50>

segment

Value:
<glue.ligolw.lsctables.segmentproperty object at 0x7f390418fb90>

start

Value:
<glue.ligolw.lsctables.gpsproperty object at 0x7f390418fb10>