|
| 1 | +import unittest |
| 2 | +from enum import Enum |
| 3 | +import z3 |
| 4 | +from scipy.stats import norm, kstest |
| 5 | + |
| 6 | +from causal_testing.specification.capabilities import Capability, TreatmentSequence |
| 7 | + |
| 8 | + |
| 9 | +class TestCapability(unittest.TestCase): |
| 10 | + |
| 11 | + """ |
| 12 | + Test the Capability class for basic methods. |
| 13 | + """ |
| 14 | + |
| 15 | + def setUp(self) -> None: |
| 16 | + pass |
| 17 | + |
| 18 | + def test_repr(self): |
| 19 | + cap = Capability("v", 1, 0, 1) |
| 20 | + self.assertEqual(str(cap), "(v, 1, 0-1)") |
| 21 | + |
| 22 | + |
| 23 | +class TestTreatmentSequence(unittest.TestCase): |
| 24 | + |
| 25 | + """ |
| 26 | + Test the TreatmentSequence class for basic methods. |
| 27 | + """ |
| 28 | + |
| 29 | + def setUp(self) -> None: |
| 30 | + self.timesteps_per_intervention = 1 |
| 31 | + |
| 32 | + def test_set_value(self): |
| 33 | + treatment_strategy = TreatmentSequence(self.timesteps_per_intervention, [("t", 1), ("t", 1), ("t", 1)]) |
| 34 | + treatment_strategy.set_value(0, 0) |
| 35 | + self.assertEqual([x.value for x in treatment_strategy.capabilities], [0, 1, 1]) |
| 36 | + |
| 37 | + def test_copy(self): |
| 38 | + control_strategy = TreatmentSequence(self.timesteps_per_intervention, [("t", 1), ("t", 1), ("t", 1)]) |
| 39 | + treatment_strategy = control_strategy.copy() |
| 40 | + treatment_strategy.set_value(0, 0) |
| 41 | + self.assertEqual([x.value for x in control_strategy.capabilities], [1, 1, 1]) |
| 42 | + self.assertEqual([x.value for x in treatment_strategy.capabilities], [0, 1, 1]) |
0 commit comments