Skip to content

Commit 013513b

Browse files
authored
[ENH] Simulation module for data-generating graphical models emphasizing usage with discrete data (#82)
* Begin work on discrete sampling * Add nvidia install for pgmpy * Fix codecov --------- Signed-off-by: Adam Li <adam2392@gmail.com>
1 parent 2a54a84 commit 013513b

62 files changed

Lines changed: 4918 additions & 568 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,19 @@ jobs:
6565
name: Install pysal dependencies
6666
command: |
6767
sudo apt install libspatialindex-dev xdg-utils shared-mime-info desktop-file-utils
68+
- run:
69+
name: Setup torch for pgmpy
70+
command: |
71+
sudo apt-get install nvidia-cuda-toolkit nvidia-cuda-toolkit-gcc
72+
6873
- run:
6974
name: Setup pandoc
7075
command: sudo apt update && sudo apt install -y pandoc optipng
7176

7277
- python/install-packages:
7378
pkg-manager: poetry
74-
cache-version: "v2" # change to clear cache
75-
args: "--with docs --extras viz"
79+
cache-version: "v1" # change to clear cache
80+
args: "--with docs --extras viz --extras sims"
7681
- run:
7782
name: Check poetry package versions
7883
command: |
@@ -87,28 +92,28 @@ jobs:
8792
- run:
8893
name: Build documentation
8994
command: |
90-
cd docs
95+
cd doc
9196
poetry run poe build_docs
9297
# Save the example test results
9398
- store_test_results:
94-
path: docs/_build/test-results
99+
path: doc/_build/test-results
95100
- store_artifacts:
96-
path: docs/_build/test-results
101+
path: doc/_build/test-results
97102
destination: test-results
98103
# Save the SG RST
99104
- store_artifacts:
100-
path: docs/auto_examples.zip
105+
path: doc/auto_examples.zip
101106
- store_artifacts:
102-
path: docs/generated.zip
107+
path: doc/generated.zip
103108
# Save the outputs
104109
- store_artifacts:
105-
path: docs/_build/html/
110+
path: doc/_build/html/
106111
destination: dev
107112
- store_artifacts:
108-
path: docs/_build/html_stable/
113+
path: doc/_build/html_stable/
109114
destination: stable
110115
- persist_to_workspace:
111-
root: docs/_build
116+
root: doc/_build
112117
paths:
113118
- html
114119
- html_stable
@@ -152,14 +157,14 @@ jobs:
152157
- run:
153158
name: make linkcheck
154159
command: |
155-
poetry run make -C docs linkcheck
160+
poetry run make -C doc linkcheck
156161
- run:
157162
name: make linkcheck-grep
158163
when: always
159164
command: |
160-
poetry run make -C docs linkcheck-grep
165+
poetry run make -C doc linkcheck-grep
161166
- store_artifacts:
162-
path: docs/_build/linkcheck
167+
path: doc/_build/linkcheck
163168
destination: linkcheck
164169

165170
deploy:
@@ -169,7 +174,7 @@ jobs:
169174
- checkout
170175

171176
- attach_workspace:
172-
at: docs/_build
177+
at: doc/_build
173178
- run:
174179
name: Set BASH_ENV
175180
command: |
@@ -179,7 +184,7 @@ jobs:
179184
- run:
180185
name: Check docs
181186
command: |
182-
if [ ! -f docs/_build/html/index.html ] && [ ! -f docs/_build/html_stable/index.html ]; then
187+
if [ ! -f doc/_build/html/index.html ] && [ ! -f doc/_build/html_stable/index.html ]; then
183188
echo "No files found to upload (build: ${CIRCLE_BRANCH}).";
184189
circleci-agent step halt;
185190
fi;
@@ -200,10 +205,10 @@ jobs:
200205
command: |
201206
if [ "${CIRCLE_BRANCH}" == "main" ]; then
202207
echo "Deploying dev doc for ${CIRCLE_BRANCH}.";
203-
node_modules/gh-pages/bin/gh-pages.js --dotfiles --message "doc updates [skip ci]" --dist docs/_build/html --dest ./dev
208+
node_modules/gh-pages/bin/gh-pages.js --dotfiles --message "doc updates [skip ci]" --dist doc/_build/html --dest ./dev
204209
else
205210
echo "Deploying stable doc for ${CIRCLE_BRANCH}.";
206-
node_modules/gh-pages/bin/gh-pages.js --dotfiles --message "doc updates [skip ci]" --dist docs/_build/html_stable --dest ./stable
211+
node_modules/gh-pages/bin/gh-pages.js --dotfiles --message "doc updates [skip ci]" --dist doc/_build/html_stable --dest ./stable
207212
fi;
208213
209214
workflows:

.codespellignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
raison
22
GES
3-
ges
3+
ges
4+
te
5+
fo

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ exclude =
1818
.circleci
1919
paper
2020
setup.py
21-
docs
21+
doc
2222

2323
per-file-ignores =
2424
# __init__.py files are allowed to have unused imports

.github/workflows/main.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,17 @@ jobs:
143143
run: |
144144
pip uninstall -yq networkx
145145
pip install --progress-bar off git+https://github.com/networkx/networkx
146+
147+
- name: Setup torch for pgmpy
148+
if: "matrix.os == 'ubuntu'"
149+
shell: bash
150+
run: |
151+
sudo apt-get install nvidia-cuda-toolkit nvidia-cuda-toolkit-gcc
152+
146153
- name: Run pytest # headless via Xvfb on linux
147154
run: poetry run poe unit_test
148155
- name: Upload coverage stats to codecov
149-
if: ${{ matrix.os == 'ubuntu' && matrix.python-version == '3.10' && matrix.networkx == 'stable' }}
156+
if: ${{ matrix.os == 'ubuntu' && matrix.python-version == '3.11' && matrix.networkx == 'stable' }}
150157
uses: codecov/codecov-action@v3
151158
with:
152159
files: ./coverage.xml

.github/workflows/pr_checks.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ jobs:
3737
then
3838
exit 0
3939
fi
40-
all_changelogs=$(cat ./docs/whats_new/v*.rst)
40+
all_changelogs=$(cat ./doc/whats_new/v*.rst)
4141
if [[ "$all_changelogs" =~ :pr:\`$PR_NUMBER\` ]]
4242
then
4343
echo "Changelog has been updated."
4444
# If the pull request is milestoned check the correspondent changelog
45-
if exist -f ./docs/whats_new/v${TAGGED_MILESTONE:0:4}.rst
45+
if exist -f ./doc/whats_new/v${TAGGED_MILESTONE:0:4}.rst
4646
then
47-
expected_changelog=$(cat ./docs/whats_new/v${TAGGED_MILESTONE:0:4}.rst)
47+
expected_changelog=$(cat ./doc/whats_new/v${TAGGED_MILESTONE:0:4}.rst)
4848
if [[ "$expected_changelog" =~ :pr:\`$PR_NUMBER\` ]]
4949
then
5050
echo "Changelog and milestone correspond."
@@ -58,7 +58,7 @@ jobs:
5858
else
5959
echo "A Changelog entry is missing."
6060
echo ""
61-
echo "Please add an entry to the changelog at 'docs/whats_new/v*.rst'"
61+
echo "Please add an entry to the changelog at 'doc/whats_new/v*.rst'"
6262
echo "to docsument your change assuming that the PR will be merged"
6363
echo "in time for the next release of pywhy-graphs."
6464
echo ""

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ instance/
7575
.scrapy
7676

7777
# Sphinx documentation
78-
docs/_build/
78+
doc/_build/
7979

8080
# PyBuilder
8181
target/
@@ -123,7 +123,7 @@ venv.bak/
123123
# Rope project settings
124124
.ropeproject
125125

126-
# mkdocs documentation
126+
# mkdoc documentation
127127
/site
128128

129129
# mypy

CITATION.cff

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# YAML 1.2
2+
---
3+
# Metadata for citation of this software according to the CFF format (https://citation-file-format.github.io/)
4+
cff-version: 1.2.0
5+
title: 'Pywhy-Graphs: Causal graphs that are networkx-compliant for the py-why ecosystem.'
6+
abstract: 'Pywhy-Graphs is a Python library to represent causal graphs and its related algorithms using a networkx-like API in Python.'
7+
authors:
8+
- given-names: Adam
9+
family-names: Li
10+
affiliation: 'Department of Computer Science, Columbia University, New York, NY, USA'
11+
orcid: 'https://orcid.org/0000-0001-8421-365X'
12+
- given-names: Jaron
13+
family-names: Lee
14+
affiliation: 'Johns Hopkins University'
15+
email: 'jaron2005@gmail.com'
16+
- given-names: Aryan
17+
family-names: Roy
18+
affiliation: 'Manipal Institute of Technology'
19+
email: 'aryanroy5678@gmail.com'
20+
type: software
21+
repository-code: 'https://github.com/py-why/pywhy-graphs'
22+
license: MIT
23+
keywords:
24+
- causality
25+
- pywhy
26+
- graphs
27+
- networkx
28+
...

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
[![unit-tests](https://github.com/py-why/pywhy-graphs/actions/workflows/main.yml/badge.svg)](https://github.com/py-why/pywhy-graphs/actions/workflows/main.yml)
44
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
55
[![codecov](https://codecov.io/gh/py-why/pywhy-graphs/branch/main/graph/badge.svg?token=H1reh7Qwf4)](https://codecov.io/gh/py-why/pywhy-graphs)
6+
[![PyPI Download count](https://pepy.tech/badge/pywhy-graphs)](https://pepy.tech/project/pywhy-graphs)
7+
[![Latest PyPI release](https://img.shields.io/pypi/v/pywhy-graphs.svg)](https://pypi.org/project/pywhy-graphs/)
68

79
# PyWhy-Graphs
810

911
pywhy-graphs is a Python graph library that extends [networkx](https://github.com/networkx/networkx) with the notion of a `MixedEdgeGraph` to implement a light-weight API for causal graphical structures that contain mixed-edges and contain causal graph traversal algorithms.
1012

11-
Note: The API is subject to change without deprecation cycles due to the current work-in-progress `MixedEdgeGraph` class in networkx. For more information, follow the PR at https://github.com/networkx/networkx/pull/5947
12-
1313
## Why?
1414

1515
Representation of causal graphical models in Python are severely lacking.
1616

17-
PyWhy-Graphs implements a graphical API layer for ADMG, CPDAG and PAG. For causal DAGs, we recommend using the `networkx.DiGraph` class and
17+
PyWhy-Graphs implements a graphical API layer for representing commmon graphs in causal inference: ADMG, CPDAG and PAG. For causal DAGs, we recommend using the `networkx.DiGraph` class and
1818
ensuring acylicity via `networkx.is_directed_acyclic_graph` function.
1919

2020
Existing packages that aim to represent causal graphs either break from the networkX API, or only implement a subset of the relevant causal graphs. By keeping in-line with the robust NetworkX API, we aim to ensure a consistent user experience and a gentle introduction to causal graphical models. A `MixedEdgeGraph` instance is a composition of networkx graphs and has a similar API, with the additional notion of an "edge type", which specifies what edge type subgraph any function should operate over. For example:
@@ -77,3 +77,7 @@ To install the package from github, clone the repository and then `cd` into the
7777
Pywhy-Graphs is always looking for new contributors to help make the package better, whether it is algorithms, documentation, examples of graph usage, and more! Contributing to Pywhy-Graphs will be rewarding because you will contribute to a much needed package for causal inference.
7878

7979
See our [contributing guide](https://github.com/py-why/pywhy-graphs/CONTRIBUTING.md) for more details.
80+
81+
# Citing
82+
83+
Please refer to the Github Citation to cite the repository.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)