Skip to content

[CI] Quick fix on the docstring of ADMG, PAG algorithms typing and pyproject toml for dowhy dev dependency #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ jobs:
- run:
name: make linkcheck
command: |
make -C doc linkcheck
make -C docs linkcheck
- run:
name: make linkcheck-grep
when: always
command: |
make -C doc linkcheck-grep
make -C docs linkcheck-grep
- store_artifacts:
path: docs/_build/linkcheck
destination: linkcheck
Expand Down
6 changes: 6 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ latexpdfja:
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."

text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
Expand Down
4 changes: 2 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Installation

## Installing from source

To install **pywhy-graphs** from source, first clone [the repository](https://github.com/pywhy/pywhy-graphs):
To install **pywhy-graphs** from source, first clone [the repository](https://github.com/py-why/pywhy-graphs):


git clone https://github.com/pywhy/pywhy-graphs.git
git clone https://github.com/py-why/pywhy-graphs.git
cd pywhy-graphs

Then run installation via poetry (recommended)
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 10 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ numpy = "^1.23.0"
scipy = "^1.9.0"
networkx = { git = "https://github.com/adam2392/networkx.git", branch = 'mixededge' }
importlib-resources = { version = "*", python = "<3.9" }
dynetx = { version="*", optional=true }
dynetx = { version = "*", optional = true }
pygraphviz = { version = "*", optional = true }

[tool.poetry.group.test]
Expand All @@ -50,7 +50,7 @@ poethepoet = "^0.16.0"
pytest = "^7.1.2"
pytest-cov = "^3.0.0"
memory_profiler = { version = "^0.60.0" }
causal-learn = { version="^0.1.2.8" }
causal-learn = { version = "^0.1.2.8" }

[tool.poetry.group.style]
optional = true
Expand Down Expand Up @@ -80,18 +80,21 @@ sphinx-copybutton = { version = "^0.5.0" }
sphinx-gallery = { version = "^0.11.0" }
sphinx_rtd_theme = { version = "^1.0.0" }
graphviz = { version = "^0.20.1" }
dowhy = { version = "^0.8" }
ipython = { version = "^7.4.0" }
nbsphinx = { version = "^0.8" }
scikit-learn = { version = "^1.1.0" }
pandas = { version = "^1.1" }
dowhy = { version = "^0.8" }
scikit-learn = { version = "^1.1.0" } # needed in dowhy's package
pandas = { version = "^1.1" } # needed in dowhy's package
joblib = { version = "^1.1.0" } # needed in dowhy's package
tqdm = { version = "^4.64.0" } # needed in dowhy's package
typing-extensions = { version = "*" } # needed in dowhy's package

[tool.poetry.extras]
ts = ['dynetx']
viz = ['pygraphviz']

[build-system]
requires = ["poetry-core>=1.0.0"]
requires = ["poetry-core>=1.0.8"]
build-backend = "poetry.core.masonry.api"

[tool.poe.tasks]
Expand Down Expand Up @@ -156,12 +159,7 @@ profile = 'black'
multi_line_output = 3
line_length = 100
py_version = 38
extend_skip_glob = [
'setup.py',
'docs/*',
'examples/*',
'pywhy_graphs/__init__.py',
]
extend_skip_glob = ['setup.py', 'docs/*', 'pywhy_graphs/__init__.py']

[tool.pydocstyle]
convention = 'numpy'
Expand Down
37 changes: 22 additions & 15 deletions pywhy_graphs/algorithms/pag.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import List, Optional, Set, Tuple

import networkx as nx
import numpy as np

from pywhy_graphs import PAG
from pywhy_graphs.algorithms.generic import single_source_shortest_mixed_path
Expand Down Expand Up @@ -168,7 +167,7 @@ def is_definite_noncollider(G: PAG, node1: Node, node2: Node, node3: Node) -> bo


def discriminating_path(
graph: PAG, u: Node, a: Node, c: Node, max_path_length: int = np.inf
graph: PAG, u: Node, a: Node, c: Node, max_path_length: Optional[int] = None
) -> Tuple[bool, List[Node], Set[Node]]:
"""Find the discriminating path for <..., a, u, c>.

Expand All @@ -189,8 +188,9 @@ def discriminating_path(
A node in the graph.
c : node
A node in the graph.
max_path_length : int
The maximum distance to check in the graph.
max_path_length : optional, int
The maximum distance to check in the graph. By default None, which sets
it to 1000.

Returns
-------
Expand All @@ -201,7 +201,7 @@ def discriminating_path(
disc_path : list
The discriminating path starting from node c.
"""
if max_path_length == np.inf:
if max_path_length is None:
max_path_length = 1000

explored_nodes: Set[Node] = set()
Expand Down Expand Up @@ -312,7 +312,7 @@ def uncovered_pd_path(
graph: PAG,
u: Node,
c: Node,
max_path_length: int,
max_path_length: Optional[int] = None,
first_node: Optional[Node] = None,
second_node: Optional[Node] = None,
) -> Tuple[List[Node], bool]:
Expand All @@ -331,8 +331,9 @@ def uncovered_pd_path(
A node in the graph to start the uncovered path.
c : node
A node in the graph.
max_path_length : int
The maximum distance to check in the graph.
max_path_length : optional, int
The maximum distance to check in the graph. By default None, which sets
it to 1000.
first_node : node, optional
The node previous to 'u'. If it is before 'u', then we will check
that 'u' is unshielded. If it is not passed, then 'u' is considered
Expand Down Expand Up @@ -361,7 +362,7 @@ def uncovered_pd_path(
):
raise RuntimeError("Some nodes are not in graph... Double check function arguments.")

if max_path_length == np.inf:
if max_path_length is None:
max_path_length = 1000

explored_nodes: Set[Node] = set()
Expand Down Expand Up @@ -454,7 +455,9 @@ def uncovered_pd_path(
return uncov_pd_path, found_uncovered_pd_path


def pds(graph: PAG, node_x: Node, node_y: Node = None, max_path_length: int = np.inf) -> Set[Node]:
def pds(
graph: PAG, node_x: Node, node_y: Node = None, max_path_length: Optional[int] = None
) -> Set[Node]:
"""Find all PDS sets between node_x and node_y.

Parameters
Expand All @@ -465,8 +468,9 @@ def pds(graph: PAG, node_x: Node, node_y: Node = None, max_path_length: int = np
The node 'x'.
node_y : node
The node 'y'.
max_path_length : int
The maximum length of a path to search on.
max_path_length : optional, int
The maximum length of a path to search on. By default None, which sets
it to 1000.

Returns
-------
Expand All @@ -492,7 +496,7 @@ def pds(graph: PAG, node_x: Node, node_y: Node = None, max_path_length: int = np
----------
.. footbibliography::
"""
if max_path_length == np.inf:
if max_path_length is None:
max_path_length = 1000

distance = 0
Expand Down Expand Up @@ -606,7 +610,9 @@ def pds(graph: PAG, node_x: Node, node_y: Node = None, max_path_length: int = np
return dsep


def pds_path(graph: PAG, node_x: Node, node_y: Node, max_path_length: int = np.inf) -> Set[Node]:
def pds_path(
graph: PAG, node_x: Node, node_y: Node, max_path_length: Optional[int] = None
) -> Set[Node]:
"""Compute the possibly-d-separating set path.

Returns the PDS_path set defined in definition 3.4 of :footcite:`Colombo2012`.
Expand All @@ -620,7 +626,8 @@ def pds_path(graph: PAG, node_x: Node, node_y: Node, max_path_length: int = np.i
node_y : node
The ending node
max_path_length : int, optional
The maximum length of a path to search on for PDS set, by default np.inf.
The maximum length of a path to search on for PDS set, by default None, which
sets it to 1000.

Returns
-------
Expand Down
3 changes: 3 additions & 0 deletions pywhy_graphs/classes/admg.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ def bidirected_edge_name(self) -> str:
def c_components(self) -> Iterator[Set]:
"""Generate confounded components of the graph.

Note the trivial c-component of a node without bidirected
edges is the node themself.

Returns
-------
comp : iterator of sets
Expand Down