Skip to content

Commit 8830175

Browse files
committed
black
1 parent 1604d7a commit 8830175

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

examples/covasim_/doubling_beta/example_beta.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737

3838
def doubling_beta_CATE_on_csv(
39-
observational_data_path: str, simulate_counterfactuals: bool = False, verbose: bool = False
39+
observational_data_path: str, simulate_counterfactuals: bool = False, verbose: bool = False
4040
):
4141
"""Compute the CATE of increasing beta from 0.016 to 0.032 on cum_infections using the dataframe
4242
loaded from the specified path. Additionally simulate the counterfactuals by repeating the analysis
@@ -65,8 +65,9 @@ def doubling_beta_CATE_on_csv(
6565
)
6666

6767
# Add squared terms for beta, since it has a quadratic relationship with cumulative infections
68-
causal_test_result = causal_test_case.execute_test(estimator=linear_regression_estimator,
69-
data_collector=data_collector)
68+
causal_test_result = causal_test_case.execute_test(
69+
estimator=linear_regression_estimator, data_collector=data_collector
70+
)
7071

7172
# Repeat for association estimate (no adjustment)
7273
no_adjustment_linear_regression_estimator = LinearRegressionEstimator(
@@ -78,8 +79,9 @@ def doubling_beta_CATE_on_csv(
7879
df=past_execution_df,
7980
formula="cum_infections ~ beta + np.power(beta, 2)",
8081
)
81-
association_test_result = causal_test_case.execute_test(estimator=no_adjustment_linear_regression_estimator,
82-
data_collector=data_collector)
82+
association_test_result = causal_test_case.execute_test(
83+
estimator=no_adjustment_linear_regression_estimator, data_collector=data_collector
84+
)
8385

8486
# Store results for plotting
8587
results_dict["association"] = {
@@ -110,7 +112,8 @@ def doubling_beta_CATE_on_csv(
110112
formula="cum_infections ~ beta + np.power(beta, 2) + avg_age + contacts",
111113
)
112114
counterfactual_causal_test_result = causal_test_case.execute_test(
113-
estimator=linear_regression_estimator, data_collector=data_collector)
115+
estimator=linear_regression_estimator, data_collector=data_collector
116+
)
114117

115118
results_dict["counterfactual"] = {
116119
"ate": counterfactual_causal_test_result.test_value.value,

examples/lr91/example_max_conductances_test_suite.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ def effects_on_APD90(observational_data_path, test_suite):
146146
# 7. Create a data collector
147147
data_collector = ObservationalDataCollector(scenario, pd.read_csv(observational_data_path))
148148

149-
150149
# 8. Run the causal test suite
151150
causal_test_results = test_suite.execute_test_suite(data_collector, causal_specification)
152151
return causal_test_results

tests/specification_tests/test_causal_dag.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,19 @@ def test_proper_backdoor_graph(self):
174174
"""Test whether converting a Causal DAG to a proper back-door graph works correctly."""
175175
causal_dag = CausalDAG(self.dag_dot_path)
176176
proper_backdoor_graph = causal_dag.get_proper_backdoor_graph(["X1", "X2"], ["Y"])
177-
edges = set([
178-
("X1", "X2"),
179-
("X2", "V"),
180-
("X2", "D2"),
181-
("D1", "D2"),
182-
("D1", "Y"),
183-
("Y", "D3"),
184-
("Z", "X2"),
185-
("Z", "Y"),
186-
])
187-
self.assertTrue(
188-
set(proper_backdoor_graph.graph.edges).issubset(edges))
177+
edges = set(
178+
[
179+
("X1", "X2"),
180+
("X2", "V"),
181+
("X2", "D2"),
182+
("D1", "D2"),
183+
("D1", "Y"),
184+
("Y", "D3"),
185+
("Z", "X2"),
186+
("Z", "Y"),
187+
]
188+
)
189+
self.assertTrue(set(proper_backdoor_graph.graph.edges).issubset(edges))
189190

190191
def test_constructive_backdoor_criterion_should_hold(self):
191192
"""Test whether the constructive criterion holds when it should."""
@@ -195,7 +196,7 @@ def test_constructive_backdoor_criterion_should_hold(self):
195196
self.assertTrue(causal_dag.constructive_backdoor_criterion(proper_backdoor_graph, xs, ys, zs))
196197

197198
def test_constructive_backdoor_criterion_should_not_hold_not_d_separator_in_proper_backdoor_graph(
198-
self,
199+
self,
199200
):
200201
"""Test whether the constructive criterion fails when the adjustment set is not a d-separator."""
201202
causal_dag = CausalDAG(self.dag_dot_path)
@@ -204,7 +205,7 @@ def test_constructive_backdoor_criterion_should_not_hold_not_d_separator_in_prop
204205
self.assertFalse(causal_dag.constructive_backdoor_criterion(proper_backdoor_graph, xs, ys, zs))
205206

206207
def test_constructive_backdoor_criterion_should_not_hold_descendent_of_proper_causal_path(
207-
self,
208+
self,
208209
):
209210
"""Test whether the constructive criterion holds when the adjustment set Z contains a descendent of a variable
210211
on a proper causal path between X and Y."""

tests/testing_tests/test_causal_test_suite.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,3 @@ def test_execute_test_suite_multiple_estimators(self):
116116
causal_forrest_result = causal_test_case_result["CausalForestEstimator"][0]
117117
self.assertAlmostEqual(linear_regression_result.test_value.value, 4, delta=1e-1)
118118
self.assertAlmostEqual(causal_forrest_result.test_value.value, 4, delta=1e-1)
119-

0 commit comments

Comments
 (0)