Skip to content

Commit 333a61c

Browse files
committed
Black
1 parent 7e443b7 commit 333a61c

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

causal_testing/json_front/json_class.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ def _setup_test(
227227
- estimation_model - Estimator instance for the test being run
228228
"""
229229

230-
data_collector = ObservationalDataCollector(self.modelling_scenario, self.data.query(" & ".join(conditions)) if conditions else self.data)
230+
data_collector = ObservationalDataCollector(
231+
self.modelling_scenario, self.data.query(" & ".join(conditions)) if conditions else self.data
232+
)
231233
causal_test_engine = CausalTestEngine(self.causal_specification, data_collector, index_col=0)
232234

233235
minimal_adjustment_set = self.causal_specification.causal_dag.identification(causal_test_case.base_test_case)

causal_testing/specification/metamorphic_relation.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ def test_oracle(self, test_results):
136136
def to_json_stub(self, skip=True) -> dict:
137137
"""Convert to a JSON frontend stub string for user customisation"""
138138
return {
139-
"name": str(self),
140-
"estimator": "LinearRegressionEstimator",
141-
"estimate_type": "coefficient",
142-
"effect": "direct",
143-
"mutations": [self.treatment_var],
144-
"expectedEffect": {self.output_var: "SomeEffect"},
145-
"skip": skip
146-
}
139+
"name": str(self),
140+
"estimator": "LinearRegressionEstimator",
141+
"estimate_type": "coefficient",
142+
"effect": "direct",
143+
"mutations": [self.treatment_var],
144+
"expectedEffect": {self.output_var: "SomeEffect"},
145+
"skip": skip,
146+
}
147147

148148
def __str__(self):
149149
formatted_str = f"{self.treatment_var} --> {self.output_var}"
@@ -165,18 +165,17 @@ def test_oracle(self, test_results):
165165
len(test_results["fail"]) == 0
166166
), f"{str(self)}: {len(test_results['fail'])}/{len(self.tests)} tests failed."
167167

168-
169168
def to_json_stub(self, skip=True) -> dict:
170169
"""Convert to a JSON frontend stub string for user customisation"""
171170
return {
172-
"name": str(self),
173-
"estimator": "LinearRegressionEstimator",
174-
"estimate_type": "coefficient",
175-
"effect": "direct",
176-
"mutations": [self.treatment_var],
177-
"expectedEffect": {self.output_var: "NoEffect"},
178-
"skip": skip
179-
}
171+
"name": str(self),
172+
"estimator": "LinearRegressionEstimator",
173+
"estimate_type": "coefficient",
174+
"effect": "direct",
175+
"mutations": [self.treatment_var],
176+
"expectedEffect": {self.output_var: "NoEffect"},
177+
"skip": skip,
178+
}
180179

181180
def __str__(self):
182181
formatted_str = f"{self.treatment_var} _||_ {self.output_var}"

causal_testing/testing/estimators.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,9 @@ def estimate_coefficient(self, df):
541541
return ab / a
542542

543543
def estimate_unit_ate(self, bootstrap_size=100):
544-
bootstraps = sorted([self.estimate_coefficient(self.df.sample(len(self.df), replace=True)) for _ in range(bootstrap_size)])
544+
bootstraps = sorted(
545+
[self.estimate_coefficient(self.df.sample(len(self.df), replace=True)) for _ in range(bootstrap_size)]
546+
)
545547
bound = ceil((bootstrap_size * 0.05) / 2)
546548
ci_low = bootstraps[bound]
547549
ci_high = bootstraps[bootstrap_size - bound]

0 commit comments

Comments
 (0)