add_method#
- class add_method(year=None, method=None, method_pars=None, copy_from=None, split_shares=None, verbose=True, **kwargs)[source]#
Bases:
InterventionIntervention to add a new contraceptive method to the simulation at a specified time.
- Parameters:
year (float) – The year at which to activate the new method
method (Method, optional) – A Method object defining the new contraceptive method. If None, the method will be copied from the source method (specified by
copy_from).method_pars (dict, optional) – Dictionary of parameters to update the method attributes. If provided, these values will override corresponding attributes in the method object (whether it was provided directly or copied from source). If None, defaults to empty dict.
copy_from (str) – Name of the existing method to copy switching probabilities from. Also used as the source method when
method=None.split_shares (float, optional) – If provided, % who would have chosen the ‘copy_from’ method and now choose the new method
verbose (bool) – Whether to print messages when method is activated (default True)
Examples:
# Using a Method object directly new_method = fp.Method(name='new_impl', label='New Implant', efficacy=0.999, dur_use=ss.lognorm_ex(ss.years(3), ss.years(0.5)), modern=True) intv = fp.add_method(year=2010, method=new_method, copy_from='impl') # Copying from source method (method=None, method_pars=None) # Creates a copy of 'impl' with name 'impl_copy' intv = fp.add_method(year=2010, copy_from='impl') # Copying from source and overriding properties intv = fp.add_method(year=2010, method_pars={'name': 'new_inj', 'efficacy': 0.995}, copy_from='inj') # Using method object and overriding properties with method_pars base_method = fp.Method(name='new_method', efficacy=0.90) intv = fp.add_method(year=2010, method=base_method, method_pars={'efficacy': 0.998}, copy_from='impl')
Attributes
auto_state_listList of "automatic" states with boolean type (ss.BoolState) that were added via define_states()
dtGet the current module timestep
has_productCheck if the intervention has a product
nowShortcut to self.t.now()
state_dictReturn a flat dictionary (objdict) of all states
state_listReturn a flat list of all states (ss.Arr objects)
tiGet the current module timestep
timevecShortcut to self.t.timevec
Methods