csv.covariate_same

View page source

Determine Which Covariates in covariate.csv Are the Same

Prototype

# at_cascade.csv.covariate_same
def covariate_same(covariate_table) :
   assert type(covariate_table) == list
   for row in covariate_table :
      for key in row :
         type_check = str if key in [ 'node_name' , 'sex' ] else float
         assert type( row[key] ) == type_check
   #
   assert type(cov_same) == dict
   for triple in cov_same :
      assert type(triple) == tuple
      assert len(triple) == 3
   return cov_same

covariate_table

Is a list of dict representation of a covariate.csv file. All of the columns in this table have been converted to float except for node_name and sex which have type str . In addition, sex equal to both may have been added; see csv.covariate_both .

cov_name

We use cov_name for omega or one of the covariate_names that appear in this file.

cov_same

For a node_name , sex, and cov_name is covariate_table

   (node_other, sex_other, cov_other) = cov_same[ (node_name, sex, cov_name) ]
  1. If follows that cov_other == cov_name; i.e., the covariate column for these two triples is the same.

  2. For each age, time, the cov_name value corresponding to (node_name, sex, cov_name) is the same as the cov_other value corresponding to (node_other, sex_other, cov_other).

  3. There is one and only one value of (node_other, sex_other, cov_other) for all the (node_name, sex, cov_name) triples that have the same cov_name value for each age and time.

Side Effects

This routine reports and error if the age-time grid is not rectangular and the same for each (node_name, sex) pair.

Example

see csv.cov_same_xam .