6
6
7
7
8
8
class TestCausalDAGIssue90 (unittest .TestCase ):
9
-
10
9
"""
11
10
Test the CausalDAG class for the resolution of Issue 90.
12
11
"""
@@ -62,7 +61,6 @@ def test_common_cause(self):
62
61
63
62
64
63
class TestCausalDAG (unittest .TestCase ):
65
-
66
64
"""
67
65
Test the CausalDAG class for creation of Causal Directed Acyclic Graphs (DAGs).
68
66
@@ -176,19 +174,18 @@ def test_proper_backdoor_graph(self):
176
174
"""Test whether converting a Causal DAG to a proper back-door graph works correctly."""
177
175
causal_dag = CausalDAG (self .dag_dot_path )
178
176
proper_backdoor_graph = causal_dag .get_proper_backdoor_graph (["X1" , "X2" ], ["Y" ])
179
- self .assertEqual (
180
- list (proper_backdoor_graph .graph .edges ),
181
- [
182
- ("X1" , "X2" ),
183
- ("X2" , "V" ),
184
- ("X2" , "D2" ),
185
- ("D1" , "D2" ),
186
- ("D1" , "Y" ),
187
- ("Y" , "D3" ),
188
- ("Z" , "X2" ),
189
- ("Z" , "Y" ),
190
- ],
191
- )
177
+ edges = set ([
178
+ ("X1" , "X2" ),
179
+ ("X2" , "V" ),
180
+ ("X2" , "D2" ),
181
+ ("D1" , "D2" ),
182
+ ("D1" , "Y" ),
183
+ ("Y" , "D3" ),
184
+ ("Z" , "X2" ),
185
+ ("Z" , "Y" ),
186
+ ])
187
+ self .assertTrue (
188
+ set (proper_backdoor_graph .graph .edges ).issubset (edges ))
192
189
193
190
def test_constructive_backdoor_criterion_should_hold (self ):
194
191
"""Test whether the constructive criterion holds when it should."""
@@ -198,7 +195,7 @@ def test_constructive_backdoor_criterion_should_hold(self):
198
195
self .assertTrue (causal_dag .constructive_backdoor_criterion (proper_backdoor_graph , xs , ys , zs ))
199
196
200
197
def test_constructive_backdoor_criterion_should_not_hold_not_d_separator_in_proper_backdoor_graph (
201
- self ,
198
+ self ,
202
199
):
203
200
"""Test whether the constructive criterion fails when the adjustment set is not a d-separator."""
204
201
causal_dag = CausalDAG (self .dag_dot_path )
@@ -207,7 +204,7 @@ def test_constructive_backdoor_criterion_should_not_hold_not_d_separator_in_prop
207
204
self .assertFalse (causal_dag .constructive_backdoor_criterion (proper_backdoor_graph , xs , ys , zs ))
208
205
209
206
def test_constructive_backdoor_criterion_should_not_hold_descendent_of_proper_causal_path (
210
- self ,
207
+ self ,
211
208
):
212
209
"""Test whether the constructive criterion holds when the adjustment set Z contains a descendent of a variable
213
210
on a proper causal path between X and Y."""
@@ -392,7 +389,6 @@ def tearDown(self) -> None:
392
389
393
390
394
391
class TestUndirectedGraphAlgorithms (unittest .TestCase ):
395
-
396
392
"""
397
393
Test the graph algorithms designed for the undirected graph variants of a Causal DAG.
398
394
During the identification process, a Causal DAG is converted into several forms of undirected graph which allow for
0 commit comments