Skip to content

Commit 7f46e82

Browse files
authored
Merge pull request #263 from CITCOM-project/fix_exact_value_atol
Fixed exact value atol bug for negative values
2 parents 9abdcbc + 67e2a9e commit 7f46e82

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

causal_testing/testing/causal_test_outcome.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ class ExactValue(SomeEffect):
7777
def __init__(self, value: float, atol: float = None):
7878
self.value = value
7979
if atol is None:
80-
self.atol = value * 0.05
80+
self.atol = abs(value * 0.05)
8181
else:
8282
self.atol = atol
83+
if self.atol < 0:
84+
raise ValueError("Tolerance must be an absolute value.")
8385

8486
def apply(self, res: CausalTestResult) -> bool:
8587
if res.ci_valid():

tests/testing_tests/test_causal_test_outcome.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ def test_exactValue_fail(self):
189189
ev = ExactValue(5, 0.1)
190190
self.assertFalse(ev.apply(ctr))
191191

192+
def test_invalid_atol(self):
193+
with self.assertRaises(ValueError):
194+
ExactValue(5, -0.1)
195+
192196
def test_invalid(self):
193197
test_value = TestValue(type="invalid", value=5.05)
194198
ctr = CausalTestResult(

0 commit comments

Comments
 (0)