Skip to content

Commit 550ad1c

Browse files
committed
pylint
1 parent 61ab78d commit 550ad1c

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

causal_testing/specification/causal_dag.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,10 @@ def direct_effect_adjustment_sets(
291291
2019. These works use the algorithm presented by Takata et al. in their work entitled: Space-optimal,
292292
backtracking algorithms to list the minimal vertex separators of a graph, 2013.
293293
294-
:param list[str] treatments: List of treatment names.
295-
:param list[str] outcomes: List of outcome names.
294+
:param treatments: List of treatment names.
295+
:param outcomes: List of outcome names.
296+
:param nodes_to_ignore: List of nodes to exclude from tests if they appear as treatments, outcomes, or in the
297+
adjustment set.
296298
:return: A list of possible adjustment sets.
297299
:rtype: list[set[str]]
298300
"""

causal_testing/specification/metamorphic_relation.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def generate_metamorphic_relation(
269269

270270

271271
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
273273
) -> list[MetamorphicRelation]:
274274
"""Construct a list of metamorphic relations implied by the Causal DAG.
275275
@@ -279,10 +279,14 @@ def generate_metamorphic_relations(
279279
:param dag: Causal DAG from which the metamorphic relations will be generated.
280280
:param nodes_to_ignore: Set of nodes which will be excluded from causal tests.
281281
: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).
282283
283284
:return: A list containing ShouldCause and ShouldNotCause metamorphic relations.
284285
"""
285286

287+
if nodes_to_ignore is None:
288+
nodes_to_ignore = {}
289+
286290
if nodes_to_test is None:
287291
nodes_to_test = dag.graph.nodes
288292

@@ -329,7 +333,7 @@ def generate_metamorphic_relations(
329333

330334
causal_dag = CausalDAG(args.dag_path, ignore_cycles=args.ignore_cycles)
331335

332-
nodes_to_test = set(
336+
dag_nodes_to_test = set(
333337
k for k, v in nx.get_node_attributes(causal_dag.graph, "test", default=True).items() if v == "True"
334338
)
335339

@@ -339,10 +343,13 @@ def generate_metamorphic_relations(
339343
"Your causal test suite WILL NOT BE COMPLETE!"
340344
)
341345
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,
343350
)
344351
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)
346353

347354
tests = [
348355
relation.to_json_stub(skip=False)

0 commit comments

Comments
 (0)