| Home | Trees | Indices | Help | 
        
  | 
  
|---|
| 
       | 
  
A class that can perform various types of comparison tests between
arbitrary DataRow classes. The class has the following attributes:
*classA: A DataRow class. Note: this is a class, not an instance
  of a class.
*classB: A DataRow class. This can be the same type of class as
  classA, or different. Like classA, this is a class, not an instance
  of that class.
*matchCriteriaA: What column, or function of columns, to get from
  classA when doing a comparison between an instance of classA and
  an instance of classB.
*matchCriteriaB: What column, or function of columns, to get from
  classB when doing a comparison between an instance of classA and
  an instance of classB.
*_diffFunc: What function to perform to differentiate classA from classB.
  This function should be one of the functions below; it takes data to
  populate an instance of classA and an instance of classB, and returns a
  numerical value >= 0 representing the difference between these instances of
  classA and classB. This value can then be compared to the window size to
  determine if A and B are the same or not.
*window: How large of a window to use to consider an instance of
 classA equal to an instance of classB.
Example:
 >>> classA = createDataRowClass( 'sngl_inspiral' )
 >>> classB = createDataRowClass( 'sngl_inspiral' )
 >>> compF = CompareDataRows( classA, classB )
 >>> compF.set_diffFunc( compF.diffRowARowB )
 >>> compF.set_window( 0.1 )
 >>> compF.set_matchCriteriaA('mass1/mass2')
 >>> compF.set_matchCriteriaB = ('mass1/mass2')
 >>> dataA = [('mass1', '10.0'), ('mass2', '5.0')]
 >>> dataB = [('mass1', '10.1'), ('mass2', '5.0')]
 >>> compF.compare( dataA, dataB )
 True
 >>> compF.set_window(0)
 >>> compF.compare( dataA, dataB )
 False
    
  | 
|||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
      
  | 
  |||
    
  | 
|||
  
 Sets the match criteria for classA. Also sets the columns needed for the given match criteria.  | 
  
 
  | 
  
 Sets the match criteria for classB. Also sets the columns needed for the given match criteria.  | 
  
 
  | 
  
 
Retrieves which columns in the desired class is needed for the match
criteria.
Parameters
----------
AorB: str
    Either 'A' or 'B'; which class to get the columns for.
Returns
-------
needed_cols: list
    The list of needed columns; see get_needed_columns for
    details.
   | 
  
 
  | 
  
 
  | 
  
 
Returns the absolute value of the difference between a and b.
Parameters
----------
a: float or integer
b: float or integer
Returns
-------
difference: float or integer
    The abs difference between a and b.
   | 
  
 
Runs self.diffFunc on a and b and checks that that is <= self.window.
Parameters
----------
a: instance of classA row
    The data passed to the first argument of self.diffFunc.
b: instance of classB row
    The data passed to the second argument of self.diffFunc.
Returns
-------
comparison: bool
    True if self.diffFunc(a, b) is <= self.window; False otherwise.
   | 
  
 
A database wrapper for the compare functions.
Parameters
----------
args: list
    A list of values. The first len(self.neededColumnsA) is assumed to
    be the data for classA, in the order that neededColumnsA is in.
    The rest of the values are assumed to be the data for classB, in
    the order that neededColumnsB is in.
Returns
-------
comparison: bool
    The result of self.compare, where the first argument passed is
    the data from classA and the second is data from classB.
   | 
  
 
Creates a function in the given connection to a database that allows
the given diffFunc to be performed on classA and classB on the fly.
The matchCriteria and the neededColumns for each class must be already
set (this should happen simultaneously by using set_matchCriteria(A|B).
Parameters
----------
connection: sqlite3.connection
    A connection to SQLite database.
diffFunc: function
    The function to use to do comparisons; must be one of the
    functions defined in this class.
compFuncName: str
    What to call the call function in the database; must be unique.
window: float
    The size of the window to use when determining whether or not
    classA and classB are the same.
   | 
  
 
Runs self.diff on self.classA and self.classB using self.matchCriteriA
and self.matchCriteriaB. A or B can be any DataRow class; the only
requirement is that their match criteria (set by
self.matchCriteria(A|B)) be a function of their slots. Special match
criteria are 'startTime' and 'endTime'. In this case,
(start|end)_time+1e-9*(start|end)_time_ns will calculated.
Parameters
----------
dataA: list
    A list of tuples with data to populate this instance of classA.
    The first value of each tuple is the column name, the second the
    value, e.g., ('ifo', 'H1').
dataB: list
    A list of data tuples to populate this instance of classB.
Returns
-------
diff: float
    The return of self._diff(a,b), where a(b) is the matchCritieraA(B)
    function run on dataA(B).
   | 
  
 Same as diffRowARowB, except that classA is assumed to be some sort of simulation table (e.g., sim_inspiral) and classB is assumed to be some sort of single-IFO table (e.g., sngl_inspiral). This assumption only matters if 'startTime' or 'endTime' are the match criteria for classA. In that case, the observatory that recorded the event in classB is retrieved from classB.ifo. This is then used to pick out the appropriate end|start time to use from classA. For example, if H1 is the ifo in the snglData, then h_(end|start)_time+1e-9*h_(end|start)_time_ns will be retrieved from the simData.  | 
  
 Computes the eThinca distance between an instance of self.classA and an instance of self.classB. This assumes that classA inherited from the SimInspiral class and classB inherited from the SnglInspiral class.  | 
  
 Computes the eThinca distance between an instance of self.classA and an instance of self.classB. This assumes that both classA and classB inherited from the SnglInspiral class.  | 
| Home | Trees | Indices | Help | 
        
  | 
  
|---|
| Generated by Epydoc 3.0.1 on Tue Dec 12 01:21:42 2017 | http://epydoc.sourceforge.net |