Skip to content

Commit fe80b75

Browse files
committed
Fixed numpy linalg error
1 parent e6a19c7 commit fe80b75

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

causal_testing/discovery/abstract_discovery.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from itertools import permutations
1111

1212
import networkx as nx
13+
import numpy as np
1314
import pandas as pd
1415
import rustworkx as rx
1516

@@ -207,28 +208,27 @@ def evaluate_tests(self, causal_dag: CausalDAG) -> pd.DataFrame:
207208

208209
results = []
209210

210-
# We use "silent=False" here to allow for inestimable edges, but it'd be good to have a more stringent
211-
# error catching strategy to catch "genuine" problems (e.g. to do with the structure of the data)
212-
for test_case, result in zip(ctf.test_cases, ctf.run_tests(silent=False)):
213-
if result.effect_estimate is None:
211+
for test_case, result in zip(ctf.test_cases, ctf.test_cases):
212+
try:
213+
result = test_case.execute_test()
214214
results.append(
215215
{
216-
"result": TestResult.INESTIMABLE,
216+
"result": (
217+
TestResult.PASS if test_case.expected_causal_effect.apply(result) else TestResult.FAIL
218+
),
217219
"expected_effect": test_case.expected_causal_effect.__class__.__name__,
218220
"treatment": test_case.base_test_case.treatment_variable.name,
219221
"outcome": test_case.base_test_case.outcome_variable.name,
222+
"effect": effect_direction(result),
220223
}
221224
)
222-
else:
225+
except np.linalg.LinAlgError:
223226
results.append(
224227
{
225-
"result": (
226-
TestResult.PASS if test_case.expected_causal_effect.apply(result) else TestResult.FAIL
227-
),
228+
"result": TestResult.INESTIMABLE,
228229
"expected_effect": test_case.expected_causal_effect.__class__.__name__,
229230
"treatment": test_case.base_test_case.treatment_variable.name,
230231
"outcome": test_case.base_test_case.outcome_variable.name,
231-
"effect": effect_direction(result),
232232
}
233233
)
234234

0 commit comments

Comments
 (0)