Skip to content

Commit

Permalink
Merge pull request #263 from CITCOM-project/fix_exact_value_atol
Browse files Browse the repository at this point in the history
Fixed exact value atol bug for negative values
  • Loading branch information
jmafoster1 authored Feb 13, 2024
2 parents 9abdcbc + 67e2a9e commit 7f46e82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion causal_testing/testing/causal_test_outcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ class ExactValue(SomeEffect):
def __init__(self, value: float, atol: float = None):
self.value = value
if atol is None:
self.atol = value * 0.05
self.atol = abs(value * 0.05)
else:
self.atol = atol
if self.atol < 0:
raise ValueError("Tolerance must be an absolute value.")

def apply(self, res: CausalTestResult) -> bool:
if res.ci_valid():
Expand Down
4 changes: 4 additions & 0 deletions tests/testing_tests/test_causal_test_outcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ def test_exactValue_fail(self):
ev = ExactValue(5, 0.1)
self.assertFalse(ev.apply(ctr))

def test_invalid_atol(self):
with self.assertRaises(ValueError):
ExactValue(5, -0.1)

def test_invalid(self):
test_value = TestValue(type="invalid", value=5.05)
ctr = CausalTestResult(
Expand Down

0 comments on commit 7f46e82

Please sign in to comment.