Example #1
0
    def __init__(self, db, db_hierarchy, on, across, by, regressors):
        side_operations_manager.SideOperationsManager.__init__(
            self, db_hierarchy, on, across, by)
        # add column functions for the default regressors: on_AB, on_X,
        # across_AX(s), across_B(s) (but not the by(s))
        default_regressors = [on[0] + '_1', on[0] + '_2']
        # check if no across were specified
        if not (self.across_cols == set(["#across"])):
            for col in self.across_cols:
                default_regressors.append(col + '_1')
                default_regressors.append(col + '_2')
        # FIXME add default regressors only if they are not already specified ?
        # FIXME do we really need to add the columns deriving from the original
        # on and across?
        regressors = regressors + default_regressors

        # reg can be: the name of a column of the database (possibly extended),
        # the name of lookup file, the name of a script, a script under the
        # form of a string (that doesnt end by .dbfun...)
        for reg in regressors:
            # instantiate appropriate dbfun
            if reg in self.extended_cols:  # column already in db
                col, _ = self.parse_extended_column(reg)
                db_fun = dbfun_column.DBfun_Column(reg, db, col, indexed=True)
            elif len(reg) >= 6 and reg[-6:] == '.dbfun':  # lookup table
                # ask for re-interpreted indexed outputs
                db_fun = dbfun_lookuptable.DBfun_LookupTable(reg, indexed=True)
            else:  # on the fly computation
                db_fun = dbfun_compute.DBfun_Compute(reg, self.extended_cols)
            self.add(db_fun)
Example #2
0
    def __init__(self, db_hierarchy, on, across, by, filters):
        side_operations_manager.SideOperationsManager.__init__(
            self, db_hierarchy, on, across, by)
        # this case is specific to filters, it applies a generic filter to the
        # database before considering A, B and X stuff.
        self.generic = []

        # associate each of the provided filters to the appropriate point in
        # the computation flow
        # filt can be: the name of a column of the database (possibly
        # extended), the name of lookup file, the name of a script, a script
        # under the form of a string (that doesnt end by .dbfun...)
        for filt in filters:
            # instantiate appropriate dbfun
            if filt in self.extended_cols:  # column already in db
                db_fun = dbfun_column.DBfun_Column(filt, indexed=False)
                # evaluate context is wasteful in this case... not even
                # necessary to have a dbfun at all
            elif len(filt) >= 6 and filt[-6:] == '.dbfun':  # lookup table
                # ask for re-interpreted indexed outputs
                db_fun = dbfun_lookuptable.DBfun_LookupTable(
                    filt, indexed=False)
            else:  # on the fly computation
                db_fun = dbfun_compute.DBfun_Compute(filt, self.extended_cols)
            self.add(db_fun)