Skip to content

Commit adb221a

Browse files
authored
Merge pull request #229 from marcfranquesa/main
Fix `d_separated` deprecation warning
2 parents e4b5f12 + 66792ac commit adb221a

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

causallearn/utils/DAG2PAG.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import numpy as np
55
import networkx as nx
6-
from networkx.algorithms import d_separated
76

87
from causallearn.graph.Dag import Dag
98
from causallearn.graph.Edge import Edge
@@ -66,7 +65,7 @@ def dag2pag(dag: Dag, islatent: List[Node], isselection: List[Node] = []) -> Gen
6665
for Z in combinations(observed_nodes, l):
6766
if nodex in Z or nodey in Z:
6867
continue
69-
if d_separated(dg, {nodes_ids[nodex]}, {nodes_ids[nodey]}, set(nodes_ids[z] for z in Z) | set([nodes_ids[s] for s in isselection])):
68+
if nx.is_d_separator(dg, {nodes_ids[nodex]}, {nodes_ids[nodey]}, set(nodes_ids[z] for z in Z) | set([nodes_ids[s] for s in isselection])):
7069
if edge:
7170
PAG.remove_edge(edge)
7271
sepset[(nodes_ids[nodex], nodes_ids[nodey])] |= set(Z)

causallearn/utils/PCUtils/Helper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def draw_graph(nx_graph):
419419
def is_dsep(nx_graph, x, y, Z):
420420
"Return True if x and y are d-separated by the set Z in nx_graph (networkx graph object) and False otherwise"
421421
S = set([str(i) for i in Z])
422-
return nx.d_separated(nx_graph, {str(x)}, {str(y)}, S)
422+
return nx.is_d_separator(nx_graph, {str(x)}, {str(y)}, S)
423423

424424

425425
#######################################################################################################################

causallearn/utils/cit.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,8 @@ def __init__(self, data, true_dag=None, **kwargs):
529529
def __call__(self, X, Y, condition_set=None):
530530
Xs, Ys, condition_set, cache_key = self.get_formatted_XYZ_and_cachekey(X, Y, condition_set)
531531
if cache_key in self.pvalue_cache: return self.pvalue_cache[cache_key]
532-
p = float(nx.d_separated(self.true_dag, {Xs[0]}, {Ys[0]}, set(condition_set)))
533-
# pvalue is bool here: 1 if is_d_separated and 0 otherwise. So heuristic comparison-based uc_rules will not work.
532+
p = float(nx.is_d_separator(self.true_dag, {Xs[0]}, {Ys[0]}, set(condition_set)))
533+
# pvalue is bool here: 1 if is_d_separator and 0 otherwise. So heuristic comparison-based uc_rules will not work.
534534

535535
# here we use networkx's d_separation implementation.
536536
# an alternative is to use causal-learn's own d_separation implementation in graph class:

0 commit comments

Comments
 (0)