Skip to content

Commit c942537

Browse files
Merge remote-tracking branch 'origin/interaction-terms' into interaction-terms
2 parents ace2612 + aca8bf9 commit c942537

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
@@ -190,6 +190,10 @@ def test_exactValue_fail(self):
190190
ev = ExactValue(5, 0.1)
191191
self.assertFalse(ev.apply(ctr))
192192

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

0 commit comments

Comments
 (0)