Skip to content

Commit 3893049

Browse files
committed
Make tests more explicit
1 parent 43c7f99 commit 3893049

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tests/test_dsl.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,21 @@ def test_stop_the_madness(self):
6868

6969
def test_intervention(self):
7070
"""Test the invervention DSL object."""
71-
self.assert_text("W*", Intervention("W", True))
72-
self.assert_text("W", Intervention("W", False))
73-
self.assert_text("W", Intervention("W")) # False is the default
71+
self.assert_text("W*", Intervention("W", star=True))
72+
self.assert_text("W", Intervention("W", star=False))
7473
self.assert_text("W", W) # shorthand for testing purposes
7574
self.assert_text("W", -W) # An intervention from variable W
7675

7776
# inversions using the unary ~ operator
78-
self.assert_text("W", ~Intervention("W", True))
79-
self.assert_text("W*", ~Intervention("W", False)) # False is still the default
80-
self.assert_text("W*", ~Intervention("W"))
77+
self.assert_text("W", ~Intervention("W", star=True))
78+
self.assert_text("W*", ~Intervention("W", star=False))
8179
self.assert_text("W*", ~W)
8280

8381
def test_counterfactual_variable(self):
8482
"""Test the Counterfactual Variable DSL object."""
8583
# Normal instantiation
86-
self.assert_text("Y_{W}", CounterfactualVariable("Y", (-W,)))
87-
self.assert_text("Y_{W*}", CounterfactualVariable("Y", (~W,)))
84+
self.assert_text("Y_{W}", CounterfactualVariable("Y", interventions=(-W,)))
85+
self.assert_text("Y_{W*}", CounterfactualVariable("Y", interventions=(~W,)))
8886

8987
# Instantiation with list-based operand to matmul @ operator
9088
self.assert_text("Y_{W}", Variable("Y") @ [W])
@@ -95,12 +93,14 @@ def test_counterfactual_variable(self):
9593
# Instantiation with two variables
9694
self.assert_text(
9795
"Y_{X, W*}",
98-
CounterfactualVariable("Y", (Intervention("X"), ~Intervention("W"))),
96+
CounterfactualVariable(
97+
"Y", interventions=(Intervention("X", star=False), ~Intervention("W", star=False))
98+
),
9999
)
100100

101101
# Instantiation with matmul @ operator and single operand
102-
self.assert_text("Y_{W}", Y @ Intervention("W"))
103-
self.assert_text("Y_{W*}", Y @ ~Intervention("W"))
102+
self.assert_text("Y_{W}", Y @ Intervention("W", star=False))
103+
self.assert_text("Y_{W*}", Y @ ~Intervention("W", star=False))
104104

105105
# Instantiation with matmul @ operator and list operand
106106
self.assert_text("Y_{X, W*}", Y @ [X, ~W])
@@ -139,7 +139,7 @@ def test_conditional_distribution(self):
139139
self.assert_text("Y_{W} | B", Y @ W | B)
140140
self.assert_text("Y_{W} | B, C", Y @ W | B | C)
141141
self.assert_text("Y_{W, X*} | B, C", Y @ W @ ~X | B | C)
142-
self.assert_text("Y_{W, X*} | B_{N*}, C", Y @ W @ ~X | B @ Intervention("N", True) | C)
142+
self.assert_text("Y_{W, X*} | B_{N*}, C", Y @ W @ ~X | B @ Intervention("N", star=True) | C)
143143

144144
def test_joint_distribution(self):
145145
"""Test the JointProbability DSL object."""

0 commit comments

Comments
 (0)