Skip to content

Commit 79e0278

Browse files
authored
Merge pull request #95 from MunchLab/notebook-tests
Add test for notebook tutorial execution
2 parents 7b4677e + b92f6bc commit 79e0278

4 files changed

Lines changed: 152 additions & 76 deletions

File tree

.github/workflows/docs.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
name: Build and Deploy Docs
22
on:
33
push:
4-
branches: [ "main" ]
4+
branches: ["main"]
55
paths:
6-
- 'doc_source/**'
7-
- 'src/ect/**'
6+
- "doc_source/**"
7+
- "src/ect/**"
88
pull_request:
9-
branches: [ "main" ]
10-
paths:
11-
- 'doc_source/**'
12-
- 'src/ect/**'
9+
branches: ["main"]
1310

1411
jobs:
1512
docs:
@@ -20,36 +17,41 @@ jobs:
2017
- uses: actions/checkout@v4
2118
with:
2219
fetch-depth: 0
23-
20+
2421
- name: Install uv
2522
uses: astral-sh/setup-uv@v5
26-
23+
2724
- name: Set up Python
2825
uses: actions/setup-python@v4
2926
with:
3027
python-version-file: "pyproject.toml"
31-
28+
3229
- name: Install system dependencies
3330
run: |
3431
sudo apt-get update
3532
sudo apt-get install -y pandoc
36-
33+
3734
- name: Create venv and install dependencies
3835
run: |
3936
uv venv
4037
source .venv/bin/activate
4138
uv pip install -e .
42-
uv pip install sphinx sphinx-rtd-theme nbsphinx autopep8 myst-parser
43-
39+
uv pip install sphinx sphinx-rtd-theme nbsphinx autopep8 myst-parser ipykernel pandas
40+
41+
- name: Install python3 Jupyter kernel
42+
run: |
43+
source .venv/bin/activate
44+
python -m ipykernel install --user --name python3 --display-name "Python 3"
45+
4446
- name: Build documentation
4547
run: |
4648
source .venv/bin/activate
4749
make html
48-
50+
4951
- name: Deploy to GitHub Pages
5052
if: github.event_name == 'push'
5153
uses: peaceiris/actions-gh-pages@v3
5254
with:
5355
github_token: ${{ secrets.GITHUB_TOKEN }}
5456
publish_dir: ./docs
55-
force_orphan: true
57+
force_orphan: true

doc_source/conf.py

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -13,52 +13,59 @@
1313
# Add the src directory to sys.path so Sphinx can find ect.embed_complex
1414
import os
1515
import sys
16-
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src')))
17-
sys.path.insert(0, os.path.abspath('.'))
18-
sys.path.insert(0, os.path.join(os.path.dirname(__file__),'..'))
19-
sys.path.insert(0, os.path.join(os.path.dirname(__file__),'..', 'ect' ))
20-
sys.path.insert(0, os.path.join(os.path.dirname(__file__),'..', 'ect', 'ect_on_graphs'))
16+
17+
sys.path.insert(
18+
0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src"))
19+
)
20+
sys.path.insert(0, os.path.abspath("."))
21+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
22+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "ect"))
23+
sys.path.insert(
24+
0, os.path.join(os.path.dirname(__file__), "..", "ect", "ect_on_graphs")
25+
)
2126
# sys.path.insert(0, os.path.join(os.path.dirname(__file__),'..', 'teaspoon'))
2227
# sys.path.insert(0, os.path.join(os.path.dirname(__file__)))
2328
# sys.path.insert(0, os.path.join(os.path.dirname(__file__),'..','..'))
2429

2530

2631
# -- Project information -----------------------------------------------------
2732

28-
project = 'ect'
29-
copyright = '2025, MunchLab'
30-
author = 'MunchLab'
33+
project = "ect"
34+
copyright = "2025, MunchLab"
35+
author = "MunchLab"
3136

3237
# The full version, including alpha/beta/rc tags
33-
release = '0.1.5'
38+
release = "0.1.5"
3439

3540

3641
# -- General configuration ---------------------------------------------------
3742

3843
# Add any Sphinx extension module names here, as strings. They can be
3944
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4045
# ones.
41-
extensions = ['sphinx.ext.autodoc',
42-
# 'numpydoc',
43-
'sphinx.ext.coverage',
44-
'sphinx.ext.napoleon',
45-
'matplotlib.sphinxext.mathmpl',
46-
'matplotlib.sphinxext.plot_directive',
47-
'sphinx.ext.autosummary',
48-
'sphinx.ext.doctest',
49-
'sphinx.ext.intersphinx',
50-
'sphinx.ext.todo',
51-
'sphinx.ext.mathjax',
52-
'sphinx.ext.ifconfig',
53-
'sphinx.ext.viewcode',
54-
'sphinx.ext.githubpages',
55-
'myst_parser',
56-
'sphinx.ext.autosummary',
57-
'nbsphinx',
58-
'sphinx.ext.viewcode']
46+
extensions = [
47+
"sphinx.ext.autodoc",
48+
# 'numpydoc',
49+
"sphinx.ext.coverage",
50+
"sphinx.ext.napoleon",
51+
"matplotlib.sphinxext.mathmpl",
52+
"matplotlib.sphinxext.plot_directive",
53+
"sphinx.ext.autosummary",
54+
"sphinx.ext.doctest",
55+
"sphinx.ext.intersphinx",
56+
"sphinx.ext.todo",
57+
"sphinx.ext.mathjax",
58+
"sphinx.ext.ifconfig",
59+
"sphinx.ext.viewcode",
60+
"sphinx.ext.githubpages",
61+
"myst_parser",
62+
"sphinx.ext.autosummary",
63+
"nbsphinx",
64+
"sphinx.ext.viewcode",
65+
]
5966

6067
# Add any paths that contain templates here, relative to this directory.
61-
templates_path = ['_templates']
68+
templates_path = ["_templates"]
6269

6370
# List of patterns, relative to source directory, that match files and
6471
# directories to ignore when looking for source files.
@@ -71,35 +78,37 @@
7178
# The theme to use for HTML and HTML Help pages. See the documentation for
7279
# a list of builtin themes.
7380
#
74-
html_theme = 'sphinx_rtd_theme'
75-
html_logo = 'img/ECT_Logo.png'
76-
html_favicon = 'img/ECT_Logo_128x128.png'
81+
html_theme = "sphinx_rtd_theme"
82+
html_logo = "img/ECT_Logo.png"
83+
html_favicon = "img/ECT_Logo_128x128.png"
7784
html_theme_options = {
78-
'canonical_url': '',
79-
'analytics_id': 'UA-XXXXXXX-1', # Provided by Google in your dashboard
80-
'logo_only': False,
81-
# 'display_version': True, # Removed because it is unsupported
82-
'prev_next_buttons_location': 'bottom',
83-
'style_external_links': True,
84-
'style_nav_header_background': '#cececf',
85+
"canonical_url": "",
86+
"analytics_id": "UA-XXXXXXX-1", # Provided by Google in your dashboard
87+
"logo_only": False,
88+
"display_version": True,
89+
"prev_next_buttons_location": "bottom",
90+
"style_external_links": True,
91+
"style_nav_header_background": "#cececf",
8592
# Toc options
86-
'collapse_navigation': False,
87-
'sticky_navigation': True,
88-
'navigation_depth': 3,
89-
'includehidden': True,
90-
'titles_only': False,
93+
"collapse_navigation": False,
94+
"sticky_navigation": True,
95+
"navigation_depth": 3,
96+
"includehidden": True,
97+
"titles_only": False,
9198
}
9299
autodoc_default_options = {
93-
'members': True,
94-
'member-order': 'bysource',
95-
'special-members': '__init__',
96-
'undoc-members': True,
97-
'exclude-members': '__weakref__',
100+
"members": True,
101+
"member-order": "bysource",
102+
"special-members": "__init__",
103+
"undoc-members": True,
104+
"exclude-members": "__weakref__",
98105
}
99106
numpydoc_show_class_members = False
100107
autodoc_typehints = "none"
101108

102109
# Add any paths that contain custom static files (such as style sheets) here,
103110
# relative to this directory. They are copied after the builtin static files,
104111
# so a file named "default.css" will overwrite the builtin "default.css".
105-
# html_static_path = ['_static']
112+
# html_static_path = ["_static"]
113+
114+
nbsphinx_execute = "always"

doc_source/notebooks/Matisse/example_matisse.ipynb

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,55 @@
2121
"execution_count": null,
2222
"metadata": {},
2323
"outputs": [],
24-
"source": "# -----------------\n# Standard imports\n# -----------------\nimport numpy as np # for arrays\nimport matplotlib.pyplot as plt # for plotting\nfrom sklearn.decomposition import PCA # for PCA for normalization\nfrom scipy.spatial import distance_matrix\n\nfrom os import listdir # for retrieving files from directory\nfrom os.path import isfile, join # for retrieving files from directory\nfrom sklearn.manifold import MDS # for MDS\nimport pandas as pd # for loading in colors csv\nimport os\nimport zipfile\n\nimport warnings\nwarnings.filterwarnings('ignore')\n\n# ---------------------------\n# The ECT packages we'll use\n# ---------------------------\nfrom ect import ECT, EmbeddedComplex # for calculating ECTs\n# Note: EmbeddedGraph is now unified into EmbeddedComplex\n# For backward compatibility, you can still use:\n# from ect import EmbeddedGraph\n\n# Simple data paths\ndata_dir = \"outlines/\"\ncolors_path = \"colors.csv\"\n\nfile_names = [\n f for f in listdir(data_dir) if isfile(join(data_dir, f)) and f[-4:] == \".txt\"\n]\nfile_names.sort()\nprint(f\"There are {len(file_names)} files in the directory\")"
24+
"source": [
25+
"# -----------------\n",
26+
"# Standard imports\n",
27+
"# -----------------\n",
28+
"import numpy as np # for arrays\n",
29+
"import matplotlib.pyplot as plt # for plotting\n",
30+
"from sklearn.decomposition import PCA # for PCA for normalization\n",
31+
"from scipy.spatial import distance_matrix\n",
32+
"\n",
33+
"from os import listdir # for retrieving files from directory\n",
34+
"from os.path import isfile, join # for retrieving files from directory\n",
35+
"from sklearn.manifold import MDS # for MDS\n",
36+
"import pandas as pd # for loading in colors csv\n",
37+
"import os\n",
38+
"import zipfile\n",
39+
"\n",
40+
"import warnings\n",
41+
"warnings.filterwarnings('ignore')\n",
42+
"\n",
43+
"# ---------------------------\n",
44+
"# The ECT packages we'll use\n",
45+
"# ---------------------------\n",
46+
"from ect import ECT, EmbeddedComplex # for calculating ECTs\n",
47+
"# Note: EmbeddedGraph is now unified into EmbeddedComplex\n",
48+
"# For backward compatibility, you can still use:\n",
49+
"# from ect import EmbeddedGraph\n",
50+
"\n",
51+
"# Simple data paths\n",
52+
"data_dir = \"outlines/\"\n",
53+
"colors_path = \"colors.csv\"\n",
54+
"\n",
55+
"# Ensure outlines are available when running under Sphinx/CI\n",
56+
"if not os.path.isdir(data_dir):\n",
57+
" zip_path = \"outlines.zip\"\n",
58+
" if os.path.isfile(zip_path):\n",
59+
" with zipfile.ZipFile(zip_path, \"r\") as zf:\n",
60+
" zf.extractall(\".\")\n",
61+
" else:\n",
62+
" raise FileNotFoundError(\n",
63+
" \"Could not find 'outlines/' directory or 'outlines.zip'. \"\n",
64+
" \"Please download the Matisse outlines and place them next to this notebook.\"\n",
65+
" )\n",
66+
"\n",
67+
"file_names = [\n",
68+
" f for f in listdir(data_dir) if isfile(join(data_dir, f)) and f[-4:] == \".txt\"\n",
69+
"]\n",
70+
"file_names.sort()\n",
71+
"print(f\"There are {len(file_names)} files in the directory\")"
72+
]
2573
},
2674
{
2775
"cell_type": "markdown",
@@ -39,7 +87,14 @@
3987
"execution_count": null,
4088
"metadata": {},
4189
"outputs": [],
42-
"source": "i = 3\nshape = np.loadtxt(data_dir + file_names[i])\n# shape = normalize(shape)\nG = EmbeddedComplex() # Using the unified EmbeddedComplex class\nG.add_cycle(shape)\nG.plot(with_labels=False, node_size=10)"
90+
"source": [
91+
"i = 3\n",
92+
"shape = np.loadtxt(data_dir + file_names[i])\n",
93+
"# shape = normalize(shape)\n",
94+
"G = EmbeddedComplex() # Using the unified EmbeddedComplex class\n",
95+
"G.add_cycle(shape)\n",
96+
"G.plot(with_labels=False, node_size=10)"
97+
]
4398
},
4499
{
45100
"cell_type": "markdown",
@@ -133,7 +188,16 @@
133188
"execution_count": null,
134189
"metadata": {},
135190
"outputs": [],
136-
"source": "def matisse_ect(filename, ect):\n shape = np.loadtxt(data_dir + filename)\n G = EmbeddedComplex() # Using the unified EmbeddedComplex class \n G.add_cycle(shape)\n G.transform_coordinates(projection_type=\"pca\")\n G.scale_coordinates(1)\n result = ect.calculate(G)\n return result"
191+
"source": [
192+
"def matisse_ect(filename, ect):\n",
193+
" shape = np.loadtxt(data_dir + filename)\n",
194+
" G = EmbeddedComplex() # Using the unified EmbeddedComplex class \n",
195+
" G.add_cycle(shape)\n",
196+
" G.transform_coordinates(projection_type=\"pca\")\n",
197+
" G.scale_coordinates(1)\n",
198+
" result = ect.calculate(G)\n",
199+
" return result"
200+
]
137201
},
138202
{
139203
"cell_type": "markdown",
@@ -307,4 +371,4 @@
307371
},
308372
"nbformat": 4,
309373
"nbformat_minor": 2
310-
}
374+
}

pyproject.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "ect"
3-
version = "1.2.2"
3+
version = "1.2.3"
44
authors = [
55
{ name="Liz Munch", email="muncheli@msu.edu" },
66
]
@@ -12,13 +12,14 @@ classifiers = [
1212
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
1313
"Operating System :: OS Independent",
1414
]
15-
dependencies = ["numpy",
16-
"networkx",
17-
"matplotlib",
18-
"numba",
19-
"scipy",
20-
"scikit-learn"
21-
]
15+
dependencies = [
16+
"numpy",
17+
"networkx",
18+
"matplotlib",
19+
"numba",
20+
"scipy",
21+
"scikit-learn",
22+
]
2223

2324
[build-system]
2425
requires = ["setuptools>=61.0"]

0 commit comments

Comments
 (0)