@@ -121,14 +121,16 @@ def test_should_cause_metamorphic_relation_missing_relationship(self):
121
121
122
122
def test_all_metamorphic_relations_implied_by_dag (self ):
123
123
dag = CausalDAG (self .dag_dot_path )
124
+ dag .add_edge ('Z' , 'Y' ) # Add a direct path from Z to Y so M becomes a mediator
124
125
metamorphic_relations = generate_metamorphic_relations (dag )
125
126
should_cause_relations = [mr for mr in metamorphic_relations if isinstance (mr , ShouldCause )]
126
127
should_not_cause_relations = [mr for mr in metamorphic_relations if isinstance (mr , ShouldNotCause )]
127
128
128
129
# Check all ShouldCause relations are present and no extra
129
130
expected_should_cause_relations = [ShouldCause ('X1' , 'Z' , [], dag ),
130
131
ShouldCause ('Z' , 'M' , [], dag ),
131
- ShouldCause ('M' , 'Y' , [], dag ),
132
+ ShouldCause ('M' , 'Y' , ['Z' ], dag ),
133
+ ShouldCause ('Z' , 'Y' , ['M' ], dag ),
132
134
ShouldCause ('X2' , 'Z' , [], dag ),
133
135
ShouldCause ('X3' , 'M' , [], dag )]
134
136
@@ -142,12 +144,11 @@ def test_all_metamorphic_relations_implied_by_dag(self):
142
144
expected_should_not_cause_relations = [ShouldNotCause ('X1' , 'X2' , [], dag ),
143
145
ShouldNotCause ('X1' , 'X3' , [], dag ),
144
146
ShouldNotCause ('X1' , 'M' , ['Z' ], dag ),
145
- ShouldNotCause ('X1' , 'Y' , ['M ' ], dag ),
147
+ ShouldNotCause ('X1' , 'Y' , ['Z ' ], dag ),
146
148
ShouldNotCause ('X2' , 'X3' , [], dag ),
147
149
ShouldNotCause ('X2' , 'M' , ['Z' ], dag ),
148
- ShouldNotCause ('X2' , 'Y' , ['M' ], dag ),
149
- ShouldNotCause ('X3' , 'Y' , ['M' ], dag ),
150
- ShouldNotCause ('Z' , 'Y' , ['M' ], dag ),
150
+ ShouldNotCause ('X2' , 'Y' , ['Z' ], dag ),
151
+ ShouldNotCause ('X3' , 'Y' , ['M' , 'Z' ], dag ),
151
152
ShouldNotCause ('Z' , 'X3' , [], dag )]
152
153
153
154
extra_snc_relations = [sncr for sncr in should_not_cause_relations if sncr
0 commit comments