Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 8, 2024
1 parent b4481d5 commit cd82184
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions dodiscover/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Version number."""

from importlib.metadata import version # type: ignore

__version__ = version(__package__)
2 changes: 1 addition & 1 deletion dodiscover/constraint/_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def _initialize_sep_sets(self, init_graph: nx.Graph) -> SeparatingSet:
sep_set: SeparatingSet = defaultdict(lambda: defaultdict(list))

# since we are not starting from a complete graph, find the separating sets
for (node_i, node_j) in itertools.combinations(init_graph.nodes, 2):
for node_i, node_j in itertools.combinations(init_graph.nodes, 2):
if not init_graph.has_edge(node_i, node_j):
sep_set[node_i][node_j] = []
sep_set[node_j][node_i] = []
Expand Down
4 changes: 2 additions & 2 deletions dodiscover/constraint/fcialg.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def _apply_rule10(
# that:
# i) begin the uncovered pd path and
# ii) are distinct (done by construction) here
for (m, w) in combinations(graph.neighbors(a), 2): # type: ignore
for m, w in combinations(graph.neighbors(a), 2): # type: ignore
if m == c or w == c:
continue

Expand Down Expand Up @@ -763,7 +763,7 @@ def _apply_orientation_rules(self, graph: EquivalenceClass, sep_set: SeparatingS
logger.info(f"Running R1-10 for iteration {idx}")

for u in graph.nodes:
for (a, c) in permutations(graph.neighbors(u), 2):
for a, c in permutations(graph.neighbors(u), 2):
logger.debug(f"Check {u} {a} {c}")

# apply R1-3 to orient triples and arrowheads
Expand Down
2 changes: 1 addition & 1 deletion dodiscover/constraint/intervention.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def _apply_orientation_rules(self, graph: EquivalenceClass, sep_set: SeparatingS
logger.info(f"Running R1-10 for iteration {idx}")

for u in graph.nodes:
for (a, c) in permutations(graph.neighbors(u), 2):
for a, c in permutations(graph.neighbors(u), 2):
logger.debug(f"Check {u} {a} {c}")

# apply R1-3 to orient triples and arrowheads
Expand Down
2 changes: 1 addition & 1 deletion dodiscover/constraint/pcalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def _apply_meek_rule3(self, graph: EquivalenceClass, i: Column, j: Column) -> bo
if graph.has_edge(i, j, graph.undirected_edge_name):
# For all the pairs of nodes adjacent to i,
# look for (k, l), such that j -> l and k -> l
for (k, l) in combinations(graph.neighbors(i), 2):
for k, l in combinations(graph.neighbors(i), 2):
# Skip if k and l are adjacent.
if l in graph.neighbors(k):
continue
Expand Down
2 changes: 1 addition & 1 deletion dodiscover/constraint/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ def _prep_second_stage_skeleton(self, context: Context) -> Context:
# Update the Context:
# add the corresponding intermediate PAG now to the context
# new initialization graph
for (_, _, d) in new_init_graph.edges(data=True):
for _, _, d in new_init_graph.edges(data=True):
if "test_stat" in d:
d.pop("test_stat")
if "pvalue" in d:
Expand Down
12 changes: 6 additions & 6 deletions dodiscover/toporder/cam.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ def _update_directed_paths(self, parent: int, child: int, directed_paths: NDArra
directed_paths : np.ndarray
Existing directed paths in the graph.
"""
directed_paths[
parent, child
] = 1 # directed_paths[i,j]=1 if there is a directed path from i to j
directed_paths[parent, child] = (
1 # directed_paths[i,j]=1 if there is a directed path from i to j
)
child_descendants = np.argwhere(directed_paths[child, :])
parent_ancestors = np.argwhere(directed_paths[:, parent])
for p in parent_ancestors: # add path from every ancestor to every descendant
Expand Down Expand Up @@ -240,9 +240,9 @@ def _initialize_score(self, X: NDArray, directed_paths: NDArray) -> Tuple[NDArra

# Initialize matrix of score gains and vector of initial scores
score_gains = np.zeros((d, d))
score_gains[
np.transpose(directed_paths == 1, (1, 0))
] = self.inf # avoid cycles setting entries to -Inf according to current directed_paths
score_gains[np.transpose(directed_paths == 1, (1, 0))] = (
self.inf
) # avoid cycles setting entries to -Inf according to current directed_paths
nodes_variance = np.var(X, axis=0)
init_score = -np.log(nodes_variance)

Expand Down
1 change: 1 addition & 0 deletions examples/plot_pc_alg.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
.. currentmodule:: dodiscover
"""

# %%
# Authors: Adam Li <[email protected]>
#
Expand Down
1 change: 0 additions & 1 deletion examples/plot_psifci_alg.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
.. currentmodule:: dodiscover
"""


# %%
# Authors: Adam Li <[email protected]>
#
Expand Down
1 change: 1 addition & 0 deletions examples/plot_score_alg.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
.. currentmodule:: dodiscover
"""

# %%
# Authors: Francesco Montagna <[email protected]>
#
Expand Down
1 change: 1 addition & 0 deletions tests/unit_tests/replearning/test_gin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests wrapper for GIN algorithm from causal"""

import networkx as nx
import numpy as np
import pandas as pd
Expand Down

0 comments on commit cd82184

Please sign in to comment.