Skip to content

Commit

Permalink
Merge pull request #161 from zhi-yi-huang/issue#129
Browse files Browse the repository at this point in the history
Fixed Issue#129
  • Loading branch information
kunwuz authored Jan 23, 2024
2 parents e17f847 + a9be7eb commit 0991c80
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions causallearn/utils/PCUtils/SkeletonDiscovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ def skeleton_discovery(
else:
if verbose:
print('%d dep %d | %s with p-value %f\n' % (x, y, S, p))
append_value(cg.sepset, x, y, tuple(sepsets))
append_value(cg.sepset, y, x, tuple(sepsets))
if (x, y) in edge_removal or not cg.G.get_edge(cg.G.nodes[x], cg.G.nodes[y]):
append_value(cg.sepset, x, y, tuple(sepsets))
append_value(cg.sepset, y, x, tuple(sepsets))

if show_progress:
pbar.refresh()
Expand Down
18 changes: 18 additions & 0 deletions tests/TestSkeletonDiscovery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from unittest import TestCase
import numpy as np
from causallearn.search.ConstraintBased.PC import pc
import networkx as nx
from causallearn.utils.cit import chisq, fisherz, gsq, kci, mv_fisherz, d_separation


class TestSkeletonDiscovery(TestCase):
def test_sepset(self):
truth_DAG_directed_edges = {(0, 2), (1, 2), (2, 3), (2, 4)}

true_dag_netx = nx.DiGraph()
true_dag_netx.add_nodes_from(list(range(5)))
true_dag_netx.add_edges_from(truth_DAG_directed_edges)

data = np.zeros((100, len(true_dag_netx.nodes))) # just a placeholder
cg = pc(data, 0.05, d_separation, True, 0, -1, true_dag=true_dag_netx)
assert cg.sepset[0, 2] is None

0 comments on commit 0991c80

Please sign in to comment.