test_num#

class test_num(daily_tests, symp_test=100.0, quar_test=1.0, quar_policy=None, subtarget=None, ili_prev=None, sensitivity=1.0, loss_prob=0, test_delay=0, start_day=0, end_day=None, swab_delay=None, **kwargs)[source]#

Bases: Intervention

Test the specified number of people per day. Useful for including historical testing data. The probability of a given person getting a test is dependent on the total number of tests, population size, and odds ratios. Compare this intervention with cv.test_prob().

Parameters:
  • daily_tests (arr) – number of tests per day, can be int, array, or dataframe/series; if integer, use that number every day; if ‘data’ or another string, use loaded data

  • symp_test (float) – odds ratio of a symptomatic person testing (default: 100x more likely)

  • quar_test (float) – probability of a person in quarantine testing (default: no more likely)

  • quar_policy (str) – policy for testing in quarantine: options are ‘start’ (default), ‘end’, ‘both’ (start and end), ‘daily’; can also be a number or a function, see get_quar_inds()

  • subtarget (dict) – subtarget intervention to people with particular indices (format: {‘ind’: array of indices, or function to return indices from the sim, ‘vals’: value(s) to apply}

  • ili_prev (arr) – prevalence of influenza-like-illness symptoms in the population; can be float, array, or dataframe/series

  • sensitivity (float) – test sensitivity (default 100%, i.e. no false negatives)

  • loss_prob (float) – probability of the person being lost-to-follow-up (default 0%, i.e. no one lost to follow-up)

  • test_delay (int) – days for test result to be known (default 0, i.e. results available instantly)

  • start_day (int) – day the intervention starts (default: 0, i.e. first day of the simulation)

  • end_day (int) – day the intervention ends

  • swab_delay (dict) – distribution for the delay from onset to swab; if this is present, it is used instead of test_delay

  • kwargs (dict) – passed to Intervention()

Examples:

interv = cv.test_num(daily_tests=[0.10*n_people]*npts)
interv = cv.test_num(daily_tests=[0.10*n_people]*npts, subtarget={'inds': cv.true(sim.people.age>50), 'vals': 1.2}) # People over 50 are 20% more likely to test
interv = cv.test_num(daily_tests=[0.10*n_people]*npts, subtarget={'inds': lambda sim: cv.true(sim.people.age>50), 'vals': 1.2}) # People over 50 are 20% more likely to test
interv = cv.test_num(daily_tests='data') # Take number of tests from loaded data using default column name (new_tests)
interv = cv.test_num(daily_tests='swabs_per_day') # Take number of tests from loaded data using a custom column name

Methods

initialize(sim)[source]#

Fix the dates and number of tests

finalize(sim)[source]#

Ensure variables with large memory footprints get erased