gstlal-inspiral  0.4.2
 All Classes Namespaces Files Functions Variables Pages
List of all members | Public Member Functions | Public Attributes
far.NearestLeafTree Class Reference

Public Member Functions

def __init__
def __setitem__
def __getitem__
def __delitem__
def __nonzero__
def __iadd__
def keys
def values
def items
def min
def minkey
def max
def maxkey
def __contains__
def __len__
def __repr__
def from_xml
def to_xml

Public Attributes

 tree

Detailed Description

A simple binary tree in which look-ups return the value of the
closest leaf.  Only float objects are supported for the keys and
values.  Look-ups raise KeyError if the tree is empty.

Example:

>>> x = NearestLeafTree()
>>> x[100.0] = 120.
>>> x[104.0] = 100.
>>> x[102.0] = 110.
>>> x[90.]
120.0
>>> x[100.999]
120.0
>>> x[101.001]
110.0
>>> x[200.]
100.0
>>> del x[104]
>>> x[200.]
110.0
>>> x.keys()
[100.0, 102.0]
>>> 102 in x
True
>>> 103 in x
False
>>> x.to_xml(u"H1").write()
<Array Type="real_8" Name="H1:nearestleaftree:array">
    <Dim>2</Dim>
    <Dim>2</Dim>
    <Stream Delimiter=" " Type="Local">
        100 102
        120 110
    </Stream>
</Array>

Definition at line 369 of file far.py.

Constructor & Destructor Documentation

def far.NearestLeafTree.__init__ (   self,
  items = () 
)
Initialize a NearestLeafTree.

Example:

>>> x = NearestLeafTree()
>>> x = NearestLeafTree([(100., 120.), (104., 100.), (102., 110.)])
>>> y = {100.: 120., 104.: 100., 102.: 100.}
>>> x = NearestLeafTree(y.items())

Definition at line 408 of file far.py.

Member Function Documentation

def far.NearestLeafTree.__delitem__ (   self,
  x 
)
Example:

>>> x = NearestLeafTree([(100., 0.), (150., 1.), (200., 0.)])
>>> del x[150.]
>>> x
NearestLeafTree([(100., 0.), (200., 0.)])
>>> del x[:]
NearestLeafTree([])

Definition at line 479 of file far.py.

def far.NearestLeafTree.__setitem__ (   self,
  x,
  val 
)
Example:

>>> x = NearestLeafTree()
>>> x[100.:200.] = 0.
>>> x[150.] = 1.
>>> x
NearestLeaftree([(100, 0), (150, 1), (200, 0)])

Definition at line 422 of file far.py.

def far.NearestLeafTree.max (   self)
Return the maximum value stored in the tree.  This is O(n).

Definition at line 550 of file far.py.

def far.NearestLeafTree.maxkey (   self)
Return the maximum key stored in the tree.  This is O(1).

Definition at line 558 of file far.py.

def far.NearestLeafTree.min (   self)
Return the minimum value stored in the tree.  This is O(n).

Definition at line 534 of file far.py.

def far.NearestLeafTree.minkey (   self)
Return the minimum key stored in the tree.  This is O(1).

Definition at line 542 of file far.py.


The documentation for this class was generated from the following file: