Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Li <[email protected]>
  • Loading branch information
adam2392 committed Nov 29, 2023
1 parent 2da0c0d commit 4a1cd8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pywhy_graphs/algorithms/cpdag.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ def pdag_to_dag(G):
# if no node satisfies condition 1 and 2, then the PDAG does not
# admit a consistent extension
if not found:
raise ValueError("No consistent extension found")
print(nodes_memo)
raise ValueError(f"No consistent extension found for PDAG: {G}, {G.edges()}")
return dag


Expand Down
8 changes: 4 additions & 4 deletions pywhy_graphs/algorithms/tests/test_cpdag.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
from pywhy_graphs.testing import assert_mixed_edge_graphs_isomorphic

seed = 1234
seed = 12345
rng = np.random.default_rng(seed)


Expand Down Expand Up @@ -216,8 +216,8 @@ def test_pdag_to_dag_1(self):
def test_pdag_to_cpdag(self):
# construct a random DAG
n = 10
p = 0.5
random_graph = nx.fast_gnp_random_graph(n, p, directed=True)
p = 0.4
random_graph = nx.fast_gnp_random_graph(n, p, directed=True, seed=seed)
dag = nx.DiGraph([(u, v) for (u, v) in random_graph.edges() if u < v])

pdag = pywhy_nx.MixedEdgeGraph(
Expand All @@ -231,7 +231,7 @@ def test_pdag_to_cpdag(self):
# we apply a random orientation for a subset of the undirected edges
for edge in dag.edges:
if edge not in vstructs:
if rng.binomial(1, 1.0 / 3):
if rng.binomial(1, 0.3):
pdag.remove_edge(*edge)
pdag.add_edge(*edge, edge_type="undirected")

Expand Down
6 changes: 6 additions & 0 deletions pywhy_graphs/networkx/classes/mixededge.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ def __init__(self, graphs=None, edge_types=None, **attr):
# load graph attributes (must be after convert)
self.graph.update(attr)

# XXX: experimental. Fix this in doc string once finalized.
# make dynamic property names for the edges, (i.e. circle_edges,
# directed_edges, undirected_edges)
for edge_type_name in self.edge_types:
setattr(self, f"{edge_type_name}_edges", self.get_graphs(edge_type_name).edges)

def __str__(self):
"""Returns a short summary of the graph.
Expand Down

0 comments on commit 4a1cd8f

Please sign in to comment.