@@ -32,9 +32,6 @@ def apply(self, res: CausalTestResult) -> bool:
32
32
return (1 < res .ci_low () < res .ci_high ()) or (res .ci_low () < res .ci_high () < 1 )
33
33
raise ValueError (f"Test Value type { res .test_value .type } is not valid for this TestOutcome" )
34
34
35
- def __str__ (self ):
36
- return "Changed"
37
-
38
35
39
36
class NoEffect (CausalTestOutcome ):
40
37
"""An extension of TestOutcome representing that the expected causal effect should be zero."""
@@ -46,9 +43,6 @@ def apply(self, res: CausalTestResult) -> bool:
46
43
return (res .ci_low () < 1 < res .ci_high ()) or np .isclose (res .test_value .value , 1.0 , atol = 1e-10 )
47
44
raise ValueError (f"Test Value type { res .test_value .type } is not valid for this TestOutcome" )
48
45
49
- def __str__ (self ):
50
- return "Unchanged"
51
-
52
46
53
47
class ExactValue (SomeEffect ):
54
48
"""An extension of TestOutcome representing that the expected causal effect should be a specific value."""
@@ -61,30 +55,33 @@ def __init__(self, value: float, tolerance: float = None):
61
55
self .tolerance = tolerance
62
56
63
57
def apply (self , res : CausalTestResult ) -> bool :
64
- super ().apply ()
58
+ if res .ci_valid ():
59
+ return super ().apply (res ) and np .isclose (res .test_value .value , self .value , atol = self .tolerance )
65
60
return np .isclose (res .test_value .value , self .value , atol = self .tolerance )
66
61
67
62
def __str__ (self ):
68
63
return f"ExactValue: { self .value } ±{ self .tolerance } "
69
64
70
65
71
- class Positive (SomeEffect ):
66
+ class Positive (CausalTestOutcome ):
72
67
"""An extension of TestOutcome representing that the expected causal effect should be positive."""
73
68
74
69
def apply (self , res : CausalTestResult ) -> bool :
75
- super ().apply ()
70
+ if res .ci_valid () and not super ().apply (res ):
71
+ return False
76
72
if res .test_value .type == "ate" :
77
73
return res .test_value .value > 0
78
74
if res .test_value .type == "risk_ratio" :
79
75
return res .test_value .value > 1
80
76
raise ValueError (f"Test Value type { res .test_value .type } is not valid for this TestOutcome" )
81
77
82
78
83
- class Negative (SomeEffect ):
79
+ class Negative (CausalTestOutcome ):
84
80
"""An extension of TestOutcome representing that the expected causal effect should be negative."""
85
81
86
82
def apply (self , res : CausalTestResult ) -> bool :
87
- super ().apply ()
83
+ if res .ci_valid () and not super ().apply (res ):
84
+ return False
88
85
if res .test_value .type == "ate" :
89
86
return res .test_value .value < 0
90
87
if res .test_value .type == "risk_ratio" :
0 commit comments