@@ -269,7 +269,7 @@ def generate_metamorphic_relation(
269
269
270
270
271
271
def generate_metamorphic_relations (
272
- dag : CausalDAG , nodes_to_ignore : set = {} , threads : int = 0 , nodes_to_test : set = None
272
+ dag : CausalDAG , nodes_to_ignore : set = None , threads : int = 0 , nodes_to_test : set = None
273
273
) -> list [MetamorphicRelation ]:
274
274
"""Construct a list of metamorphic relations implied by the Causal DAG.
275
275
@@ -279,10 +279,14 @@ def generate_metamorphic_relations(
279
279
:param dag: Causal DAG from which the metamorphic relations will be generated.
280
280
:param nodes_to_ignore: Set of nodes which will be excluded from causal tests.
281
281
:param threads: Number of threads to use (if generating in parallel).
282
+ :param nodes_to_ignore: Set of nodes to test the relationships between (defaults to all nodes).
282
283
283
284
:return: A list containing ShouldCause and ShouldNotCause metamorphic relations.
284
285
"""
285
286
287
+ if nodes_to_ignore is None :
288
+ nodes_to_ignore = {}
289
+
286
290
if nodes_to_test is None :
287
291
nodes_to_test = dag .graph .nodes
288
292
@@ -329,7 +333,7 @@ def generate_metamorphic_relations(
329
333
330
334
causal_dag = CausalDAG (args .dag_path , ignore_cycles = args .ignore_cycles )
331
335
332
- nodes_to_test = set (
336
+ dag_nodes_to_test = set (
333
337
k for k , v in nx .get_node_attributes (causal_dag .graph , "test" , default = True ).items () if v == "True"
334
338
)
335
339
@@ -339,10 +343,13 @@ def generate_metamorphic_relations(
339
343
"Your causal test suite WILL NOT BE COMPLETE!"
340
344
)
341
345
relations = generate_metamorphic_relations (
342
- causal_dag , nodes_to_test = nodes_to_test , nodes_to_ignore = set (causal_dag .cycle_nodes ()), threads = args .threads
346
+ causal_dag ,
347
+ nodes_to_test = dag_nodes_to_test ,
348
+ nodes_to_ignore = set (causal_dag .cycle_nodes ()),
349
+ threads = args .threads ,
343
350
)
344
351
else :
345
- relations = generate_metamorphic_relations (causal_dag , nodes_to_test = nodes_to_test , threads = args .threads )
352
+ relations = generate_metamorphic_relations (causal_dag , nodes_to_test = dag_nodes_to_test , threads = args .threads )
346
353
347
354
tests = [
348
355
relation .to_json_stub (skip = False )
0 commit comments