Configures the exp object by adding parameters for all user-specified interventions.
This function checks the list of interventions in the exp object and updates the
object with the necessary parameters for each supported intervention. If no
interventions are specified, a message is printed. If an invalid intervention is
specified, a ValueError is raised.
Currently, the function supports the ccstep intervention and includes a placeholder
for other potential interventions (e.g., smc).
| Parameters: |
-
exp
(object)
–
An object representing the experiment, which should have an
intervention_list attribute (a list of strings specifying interventions).
|
| Returns: |
-
object –
The updated exp object with added parameters for specified interventions.
|
| Raises: |
-
ValueError
–
If an invalid intervention is specified in the intervention_list.
|
Source code in utility/helper_interventions.py
| def exp_params_to_update(exp):
"""
Configures the `exp` object by adding parameters for all user-specified interventions.
This function checks the list of interventions in the `exp` object and updates the
object with the necessary parameters for each supported intervention. If no
interventions are specified, a message is printed. If an invalid intervention is
specified, a `ValueError` is raised.
Currently, the function supports the `ccstep` intervention and includes a placeholder
for other potential interventions (e.g., `smc`).
Args:
exp (object): An object representing the experiment, which should have an
`intervention_list` attribute (a list of strings specifying interventions).
Returns:
object: The updated `exp` object with added parameters for specified interventions.
Raises:
ValueError: If an invalid intervention is specified in the `intervention_list`.
"""
# Note having unique levels of those two parameters is currently needed in the plotting scripts
exp.cm_clinical = [x[0] for x in exp.case_management]
exp.cm_severe = [x[1] for x in exp.case_management]
exp.intervention_analyzer_columns = []
if not exp.intervention_list or exp.intervention_list == []:
print('No interventions specified')
else:
if 'ccstep' in exp.intervention_list:
print('Adding parameters for ccstep')
exp = ccstep_params(exp)
else:
raise ValueError('Invalid intervention specified. Note that case management is automatically included.')
# if 'smc' in exp.intervention_list:
# print('Adding parameters for smc')
# exp = smc_params(exp)
return exp
|