1
1
from typing import Any
2
2
3
- from causal_testing .testing .intervention import Intervention
4
3
from causal_testing .testing .causal_test_outcome import CausalTestOutcome
5
4
from causal_testing .specification .variable import Variable
6
5
@@ -18,9 +17,8 @@ class CausalTestCase:
18
17
"""
19
18
20
19
def __init__ (self , control_input_configuration : dict [Variable : Any ], expected_causal_effect : CausalTestOutcome ,
21
- outcome_variables : dict [Variable ], intervention : Intervention = None ,
22
- treatment_input_configuration : dict [Variable : Any ] = None , estimate_type : str = "ate" ,
23
- effect_modifier_configuration : dict [Variable : Any ] = None ):
20
+ outcome_variables : dict [Variable ], treatment_input_configuration : dict [Variable : Any ] = None ,
21
+ estimate_type : str = "ate" , effect_modifier_configuration : dict [Variable : Any ] = None ):
24
22
"""
25
23
When a CausalTestCase is initialised, it takes the intervention and applies it to the input configuration to
26
24
create two distinct input configurations: a control input configuration and a treatment input configuration.
@@ -29,35 +27,18 @@ def __init__(self, control_input_configuration: dict[Variable: Any], expected_ca
29
27
30
28
:param control_input_configuration: The input configuration representing the control values of the treatment
31
29
variables.
32
- :param intervention: The function which transforms the control configuration to the treatment configuration.
33
- Defaults to None.
34
30
:param treatment_input_configuration: The input configuration representing the treatment values of the treatment
35
31
variables. That is, the input configuration *after* applying the intervention.
36
32
"""
37
- assert (
38
- intervention is None or treatment_input_configuration is None
39
- ), 'Cannot define both treatment configuration and intervention.'
40
- assert (
41
- intervention is not None or treatment_input_configuration is not None
42
- ), 'Must define either a treatment configuration or intervention.'
43
- if intervention is not None :
44
- assert isinstance (intervention , Intervention ), \
45
- f'Intervention must be an instance of class Intervention not { type (intervention )} .'
46
-
47
33
self .control_input_configuration = control_input_configuration
48
34
self .expected_causal_effect = expected_causal_effect
49
- self .intervention = intervention
50
35
self .outcome_variables = outcome_variables
51
36
self .treatment_input_configuration = treatment_input_configuration
52
37
self .estimate_type = estimate_type
53
38
if effect_modifier_configuration :
54
39
self .effect_modifier_configuration = effect_modifier_configuration
55
40
else :
56
41
self .effect_modifier_configuration = dict ()
57
- if intervention :
58
- self .treatment_input_configuration = intervention .apply (
59
- self .control_input_configuration
60
- )
61
42
assert self .control_input_configuration .keys () == self .treatment_input_configuration .keys (),\
62
43
"Control and treatment input configurations must have the same keys."
63
44
@@ -78,12 +59,7 @@ def get_treatment_values(self):
78
59
return list (self .treatment_input_configuration .values ())
79
60
80
61
def __str__ (self ):
81
- if self .intervention is not None :
82
- control_input_configuration = {k .name : v for k , v in self .control_input_configuration .items ()}
83
- return (f"Applying { self .intervention } to { control_input_configuration } should cause the following "
84
- f"changes to { [v .name for v in self .outcome_variables ]} : { self .expected_causal_effect } ." )
85
- else :
86
- treatment_config = {k .name : v for k , v in self .treatment_input_configuration .items ()}
87
- control_config = {k .name : v for k , v in self .control_input_configuration .items ()}
88
- return (f"Running { treatment_config } instead of { control_config } should cause the following "
89
- f"changes to { self .outcome_variables } : { self .expected_causal_effect } ." )
62
+ treatment_config = {k .name : v for k , v in self .treatment_input_configuration .items ()}
63
+ control_config = {k .name : v for k , v in self .control_input_configuration .items ()}
64
+ return (f"Running { treatment_config } instead of { control_config } should cause the following "
65
+ f"changes to { self .outcome_variables } : { self .expected_causal_effect } ." )
0 commit comments