|
6 | 6 | class TestCausalTestOutcome(unittest.TestCase):
|
7 | 7 | """Test the TestCausalTestOutcome basic methods."""
|
8 | 8 |
|
| 9 | + def test_None_ci(self): |
| 10 | + test_value = TestValue(type="ate", value=0) |
| 11 | + ctr = CausalTestResult( |
| 12 | + treatment="A", |
| 13 | + outcome="A", |
| 14 | + treatment_value=1, |
| 15 | + control_value=0, |
| 16 | + adjustment_set={}, |
| 17 | + test_value=test_value, |
| 18 | + confidence_intervals=[None, None], |
| 19 | + effect_modifier_configuration=None, |
| 20 | + ) |
| 21 | + |
| 22 | + self.assertIsNone(ctr.ci_low()) |
| 23 | + self.assertIsNone(ctr.ci_high()) |
| 24 | + self.assertEqual(ctr.to_dict(), |
| 25 | + {"treatment": "A", |
| 26 | + "control_value": 0, |
| 27 | + "treatment_value": 1, |
| 28 | + "outcome": "A", |
| 29 | + "adjustment_set": set(), |
| 30 | + "test_value": test_value}) |
| 31 | + |
9 | 32 | def test_empty_adjustment_set(self):
|
| 33 | + test_value = TestValue(type="ate", value=0) |
10 | 34 | ctr = CausalTestResult(
|
11 | 35 | treatment="A",
|
12 | 36 | outcome="A",
|
13 | 37 | treatment_value=1,
|
14 | 38 | control_value=0,
|
15 | 39 | adjustment_set={},
|
16 |
| - test_value=0, |
| 40 | + test_value=test_value, |
17 | 41 | confidence_intervals=None,
|
18 | 42 | effect_modifier_configuration=None,
|
19 | 43 | )
|
20 | 44 |
|
21 | 45 | self.assertIsNone(ctr.ci_low())
|
22 | 46 | self.assertIsNone(ctr.ci_high())
|
| 47 | + self.assertEqual(str(ctr), ("Causal Test Result\n==============\n" |
| 48 | + "Treatment: A\n" |
| 49 | + "Control value: 0\n" |
| 50 | + "Treatment value: 1\n" |
| 51 | + "Outcome: A\n" |
| 52 | + "Adjustment set: set()\n" |
| 53 | + "ate: 0\n" )) |
23 | 54 |
|
24 | 55 | def test_exactValue_pass(self):
|
25 | 56 | test_value = TestValue(type="ate", value=5.05)
|
@@ -80,3 +111,20 @@ def test_someEffect_fail(self):
|
80 | 111 | )
|
81 | 112 | ev = SomeEffect()
|
82 | 113 | self.assertFalse(ev.apply(ctr))
|
| 114 | + self.assertEqual(str(ctr), ("Causal Test Result\n==============\n" |
| 115 | + "Treatment: A\n" |
| 116 | + "Control value: 0\n" |
| 117 | + "Treatment value: 1\n" |
| 118 | + "Outcome: A\n" |
| 119 | + "Adjustment set: set()\n" |
| 120 | + "ate: 0\n" |
| 121 | + "Confidence intervals: [-0.1, 0.2]\n" )) |
| 122 | + self.assertEqual(ctr.to_dict(), |
| 123 | + {"treatment": "A", |
| 124 | + "control_value": 0, |
| 125 | + "treatment_value": 1, |
| 126 | + "outcome": "A", |
| 127 | + "adjustment_set": set(), |
| 128 | + "test_value": test_value, |
| 129 | + "ci_low": -0.1, |
| 130 | + "ci_high": 0.2}) |
0 commit comments