Skip to content

Commit 39a9e16

Browse files
Convert to generators
1 parent e209cbe commit 39a9e16

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

causal_testing/specification/causal_dag.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,19 +150,19 @@ def check_iv_assumptions(self, treatment, outcome, instrument) -> bool:
150150
raise ValueError(f"Instrument {instrument} is not associated with treatment {treatment} in the DAG")
151151

152152
# (ii) Instrument does not affect outcome except through its potential effect on treatment
153-
if not all([treatment in path for path in nx.all_simple_paths(self.graph, source=instrument, target=outcome)]):
153+
if not all((treatment in path for path in nx.all_simple_paths(self.graph, source=instrument, target=outcome))):
154154
raise ValueError(
155155
f"Instrument {instrument} affects the outcome {outcome} other than through the treatment {treatment}"
156156
)
157157

158158
# (iii) Instrument and outcome do not share causes
159159
if any(
160-
[
160+
(
161161
cause
162162
for cause in self.graph.nodes
163163
if list(nx.all_simple_paths(self.graph, source=cause, target=instrument))
164164
and list(nx.all_simple_paths(self.graph, source=cause, target=outcome))
165-
]
165+
)
166166
):
167167
raise ValueError(f"Instrument {instrument} and outcome {outcome} share common causes")
168168

0 commit comments

Comments
 (0)