Next / Previous / Contents / TCC Help System / NM Tech homepage

28.7. CbcHist.__init__()

The extraction of data from the pycbc.CBCData instance happens here in the constructor.

For each effort in the selected circles, find all the related census records. For each census record, place its data in the cell in the appropriate row and column (or combine it with any data that may already be there), creating new rows as necessary.

cbchistlib.py
# - - -   C b c H i s t . _ _ i n i t _ _

    def __init__(self, db, effKeyList, txny, layoutFactory,
                 cenFilter=None):
        '''Constructor.
        '''
        #-- 1
        self.db = db
        self.effKeyList = effKeyList
        self.txny = txny
        self.cenFilter = cenFilter

The layoutFactory is a class, not an instance, and it requires a list of effort keys. Also, we put a hard limit (see Section 13.7.2, “COLUMN_COUNT_LIMIT) on the total number of logical columns; much beyond that and there's not much room for data.

cbchistlib.py
        #-- 2
        # [ self._columnLayout  :=  result of calling layoutFactory
        #       with effKeyList
        #   self.nCols  :=  length of that result ]
        self._columnLayout = layoutFactory(effKeyList)
        self.nCols = len(self._columnLayout)
        if self.nCols > COLUMN_COUNT_LIMIT:
            raise ScriptError("Too many columns (%d): maximum is "
                              "%d." % (self.nCols, COLUMN_COUNT_LIMIT))

For the .keyRow and .partyHoursRow attributes, see Section 30, “class KeyRow: The first heading line” and Section 32, “class PartyHoursRow: Heading row showing total effort”.

cbchistlib.py
        #-- 3
        # [ self.keyRow  :=  as invariant ]
        self.keyRow = KeyRow(self)

        #-- 4
        # [ self.partyHoursRow  :=  as invariant ]
        self.partyHoursRow = PartyHoursRow(self)

See Section 28.8, “CbcHist._buildCensusRows(): Build the census rows” for the construction of the census logical rows.

cbchistlib.py
        #-- 5
        # [ self._rowMap  :=  as invariant using census data from
        #       db filtered by self.cenFilter ]
        self._buildCensusRows()