Skip to content

Commit aca8bf9

Browse files
Merge branch 'main' into interaction-terms
2 parents da87421 + 7f46e82 commit aca8bf9

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
@@ -78,9 +78,11 @@ class ExactValue(SomeEffect):
7878
def __init__(self, value: float, atol: float = None):
7979
self.value = value
8080
if atol is None:
81-
self.atol = value * 0.05
81+
self.atol = abs(value * 0.05)
8282
else:
8383
self.atol = atol
84+
if self.atol < 0:
85+
raise ValueError("Tolerance must be an absolute value.")
8486

8587
def apply(self, res: CausalTestResult) -> bool:
8688
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)