Skip to content

Commit 87a5425

Browse files
update docs with concrete tests
1 parent 70d4c1f commit 87a5425

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

causal_testing/json_front/json_class.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def run_json_tests(self, effects: dict, estimators: dict, f_flag: bool = False,
102102
self._append_to_file(msg, logging.INFO)
103103
else:
104104
outcome_variable = next(
105-
iter(test["expectedEffect"])
105+
iter(test["expected_effect"])
106106
) # Take first key from dictionary of expected effect
107107
base_test_case = BaseTestCase(
108108
treatment_variable=self.variables["inputs"][test["treatment_variable"]],
@@ -111,7 +111,7 @@ def run_json_tests(self, effects: dict, estimators: dict, f_flag: bool = False,
111111

112112
causal_test_case = CausalTestCase(
113113
base_test_case=base_test_case,
114-
expected_causal_effect=effects[test["expectedEffect"][outcome_variable]],
114+
expected_causal_effect=effects[test["expected_effect"][outcome_variable]],
115115
control_value=test["control_value"],
116116
treatment_value=test["treatment_value"],
117117
estimate_type=test["estimate_type"],
@@ -141,7 +141,7 @@ def _create_abstract_test_case(self, test, mutates, effects):
141141
treatment_variable=next(self.scenario.variables[v] for v in test["mutations"]),
142142
expected_causal_effect={
143143
self.scenario.variables[variable]: effects[effect]
144-
for variable, effect in test["expectedEffect"].items()
144+
for variable, effect in test["expected_effect"].items()
145145
},
146146
effect_modifiers={self.scenario.variables[v] for v in test["effect_modifiers"]}
147147
if "effect_modifiers" in test

docs/source/frontends/json_front_end.rst

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,28 @@ Use case specific information is also declared here such as the paths to the rel
2121

2222
causal_tests.json
2323
-----------------
24-
`examples/poisson/causal_tests.json <https://github.com/CITCOM-project/CausalTestingFramework/blob/main/examples/poisson/causal_tests.json>`_ contains python code written by the user to implement scenario specific features
25-
is the JSON file that allows for the easy specification of multiple causal tests.
24+
`examples/poisson/causal_tests.json <https://github.c#om/CITCOM-project/CausalTestingFramework/blob/main/examples/poisson/causal_tests.json>`_ contains python code written by the user to implement scenario specific features
25+
is the JSON file that allows for the easy specification of multiple causal tests. Tests can be specified two ways; firstly by specifying a mutation lke in the example tests with the following structure:
2626
Each test requires:
27-
1. Test name
28-
2. Mutations
29-
3. Estimator
30-
4. Estimate_type
31-
5. Effect modifiers
32-
6. Expected effects
33-
7. Skip: boolean that if set true the test won't be executed and will be skipped
3427

28+
#. name
29+
#. mutations
30+
#. estimator
31+
#. estimate_type
32+
#. effect_modifiers
33+
#. expected_effects
34+
#. skip: boolean that if set true the test won't be executed and will be skipped
35+
36+
The second method of specifying a test is to specify the test in a concrete form with the following structure:
37+
38+
#. name
39+
#. treatment_variable
40+
#. control_value
41+
#. treatment_value
42+
#. estimator
43+
#. estimate_type
44+
#. expected_effect
45+
#. skip
3546

3647
Run Commands
3748
------------

tests/json_front_tests/test_json_class.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_f_flag(self):
8383
"estimator": "LinearRegressionEstimator",
8484
"estimate_type": "ate",
8585
"effect_modifiers": [],
86-
"expectedEffect": {"test_output": "NoEffect"},
86+
"expected_effect": {"test_output": "NoEffect"},
8787
"skip": False,
8888
}
8989
]
@@ -107,7 +107,7 @@ def test_run_json_tests_from_json(self):
107107
"estimator": "LinearRegressionEstimator",
108108
"estimate_type": "ate",
109109
"effect_modifiers": [],
110-
"expectedEffect": {"test_output": "NoEffect"},
110+
"expected_effect": {"test_output": "NoEffect"},
111111
"skip": False,
112112
}
113113
]
@@ -137,7 +137,7 @@ def test_run_concrete_json_testcase(self):
137137
"treatment_value": 1,
138138
"estimator": "LinearRegressionEstimator",
139139
"estimate_type": "ate",
140-
"expectedEffect": {"test_output": "NoEffect"},
140+
"expected_effect": {"test_output": "NoEffect"},
141141
"skip": False,
142142
}
143143
]

0 commit comments

Comments
 (0)