The purpose of this class is to provide an interface for computing means and standard deviations to a set of values in a logical row. There are two quite different types of rows with these cells, party-hours rows and census rows; this class exports the behavior shared between the two types, behavior which treats the content of the cell as a floating-point number.
Every instance starts out in a state where it has no value.
It remains in this state until the
method is called to add to the total.
This state is important because a lot of the early counts,
and even a few of the modern counts, did not record
party-hours of effort. If a party-hours column displays
-”, meaning that the
party-hours is unknown, it is important that that column not
participate in the computation of statistics for the
The purpose of the
.add() method is either to
put the first or only value into the cell, or to add more to
the running total. This works quite differently for
party-hours cells and census cells.
The value inside a party-hours cell is just a float (or
None when the cell is in no-value state).
CensusCell in a census row accumulates
Census records in four
different categories depending on the
q values in those records.
.__float__() method returns the
accumulated total as a Python
-1.0 if the cell should not participate
in statistical calculations. (Originally, this method
None in the latter case,
but Python complains if a
method does not return a
For party-hours cells, if it is in the no-value state,
None, otherwise it returns the
Census cells work very differently. If there is no data
in a column, it is displayed as “-”, but
for statistical purposes it does participate in the data
set, with value zero. The value returned includes only
the total number of individuals from records without
In a few cases, the number was inadvertently left off an
unflagged record, and the
attribute will be
-1. To try to minimize
the damage these records do to the statistics, the
number will be considered to have a value of 1. Careful
researchers will want to scan the history report for
occurrences of “(unk)” that signify this
# - - - - - c l a s s N u m b e r C e l l class NumberCell(Cell): '''Base class for cells containing values used in statistics. Exports: NumberCell(): [ return a new NumberCell instance with no value ] .add(value): [ value has a type appropriate for the subclass -> if self has a value -> self := self with (value) accumulated else -> self := self with value (value) ] .__float__(self): # Virtual method [ if self is a cell containing a number that is valid as input to a statistical calculation -> return that number as a float else -> return -1.0 ] ''' __slots__ = () def __init__(self): '''Constructor. ''' raise NotImplementedError("NumberCell.__init__() is a " "virtual method.") def add(self, value): '''Add value to self's total. ''' raise NotImplementedError("NumberCell.add() is a virtual " "method.") def __float__(self): raise NotImplementedError("NumberCell.__float__() is a " "virtual method.")