Skip to content

Commit 2db9803

Browse files
authored
Merge branch 'main' into uv-actions
2 parents ea125f6 + afb00a3 commit 2db9803

File tree

12 files changed

+225
-29
lines changed

12 files changed

+225
-29
lines changed

.github/pull_request_template.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
2323
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
2424
- [ ] My code follows the code style of this project. (`make clean`)
25-
- [ ] My change requires a change to the documentation.
26-
- [ ] I have updated the documentation accordingly. (`make html`)
2725
- [ ] I have incremented the version number in the `pyproject.toml` file.
2826
- [ ] I have added tests to cover my changes.
2927
- [ ] All new and existing tests passed. (`make tests`)

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
python benchmarks/run_benchmarks.py
3535
3636
- name: Store benchmark results
37-
uses: actions/upload-artifact@v3
37+
uses: actions/upload-artifact@v4
3838
with:
3939
name: benchmark-results
4040
path: benchmark_results/

.github/workflows/docs.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build and Deploy Docs
2+
on:
3+
push:
4+
branches: [ "main" ]
5+
paths:
6+
- 'doc_source/**'
7+
- 'src/ect/**'
8+
pull_request:
9+
branches: [ "main" ]
10+
paths:
11+
- 'doc_source/**'
12+
- 'src/ect/**'
13+
14+
jobs:
15+
docs:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version-file: "pyproject.toml"
31+
32+
- name: Install system dependencies
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get install -y pandoc
36+
37+
- name: Create venv and install dependencies
38+
run: |
39+
uv venv
40+
source .venv/bin/activate
41+
uv pip install -e .
42+
uv pip install sphinx sphinx-rtd-theme nbsphinx autopep8 myst-parser
43+
44+
- name: Build documentation
45+
run: |
46+
source .venv/bin/activate
47+
make html
48+
49+
- name: Deploy to GitHub Pages
50+
if: github.event_name == 'push'
51+
uses: peaceiris/actions-gh-pages@v3
52+
with:
53+
github_token: ${{ secrets.GITHUB_TOKEN }}
54+
publish_dir: ./docs
55+
force_orphan: true

Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ release:
2323
python setup.py sdist bdist_wheel
2424

2525
html:
26-
# Running sphinx-build to build html files in build folder.
27-
rm -r docs
26+
# Running sphinx-build to build html files in docs folder
27+
rm -rf docs
2828
mkdir docs
29-
sphinx-build -M html doc_source docs
30-
rsync -a docs/html/ docs/
31-
rm -r docs/html
29+
sphinx-build -b html doc_source docs
3230

3331
benchmark:
3432
python benchmarks/run_benchmarks.py

doc_source/directions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Directions
2+
3+
```{eval-rst}
4+
.. automodule:: ect.directions
5+
:members:
6+
```

doc_source/ect_on_graphs.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@
44
.. automodule:: ect.ect_graph
55
:members:
66
```
7+
8+
```{eval-rst}
9+
.. automodule:: ect.sect
10+
:members:
11+
```

doc_source/modules.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ Table of Contents
77

88
Embedded graphs <embed_graph.md>
99
Embedded CW complex <embed_cw.md>
10-
ECT on graphs <ect_on_graphs.md>
10+
ECT on graphs <ect_on_graphs.md>
11+
Directions <directions.md>

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "ect"
3-
version = "1.0.0"
3+
version = "1.0.3"
44
authors = [
55
{ name="Liz Munch", email="muncheli@msu.edu" },
66
]

src/ect/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
from .embed_graph import EmbeddedGraph
1313
from .embed_cw import EmbeddedCW
1414
from .directions import Directions
15+
from .sect import SECT
1516
from .utils import examples
1617

1718
__all__ = [
18-
'ECT',
19-
'EmbeddedGraph',
20-
'EmbeddedCW',
21-
'Directions',
22-
'examples',
19+
"ECT",
20+
"SECT",
21+
"EmbeddedGraph",
22+
"EmbeddedCW",
23+
"Directions",
24+
"examples",
2325
]

src/ect/ect_graph.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
22
from numba import prange, njit
3+
from numba.typed import List
34
from typing import Optional, Union
45

56
from .embed_cw import EmbeddedCW
@@ -55,8 +56,7 @@ def _ensure_directions(self, graph_dim, theta=None):
5556
"""Ensures directions is a valid Directions object of correct dimension"""
5657
if self.directions is None:
5758
if self.num_dirs is None:
58-
raise ValueError(
59-
"Either 'directions' or 'num_dirs' must be provided.")
59+
raise ValueError("Either 'directions' or 'num_dirs' must be provided.")
6060
self.directions = Directions.uniform(self.num_dirs, dim=graph_dim)
6161
elif isinstance(self.directions, list):
6262
# if list of vectors, convert to Directions object
@@ -127,12 +127,10 @@ def calculate(
127127

128128
# override with theta if provided
129129
directions = (
130-
self.directions if theta is None else Directions.from_angles([
131-
theta])
130+
self.directions if theta is None else Directions.from_angles([theta])
132131
)
133132

134-
simplex_projections = self._compute_simplex_projections(
135-
graph, directions)
133+
simplex_projections = self._compute_simplex_projections(graph, directions)
136134

137135
ect_matrix = self._compute_directional_transform(
138136
simplex_projections, self.thresholds, self.shape_descriptor, self.dtype
@@ -148,7 +146,7 @@ def _compute_simplex_projections(
148146
self, graph: Union[EmbeddedGraph, EmbeddedCW], directions
149147
):
150148
"""Compute projections of each simplex (vertices, edges, faces)"""
151-
simplex_projections = []
149+
simplex_projections = List()
152150
node_projections = self._compute_node_projections(
153151
graph.coord_matrix, directions
154152
)
@@ -162,11 +160,9 @@ def _compute_simplex_projections(
162160

163161
if isinstance(graph, EmbeddedCW) and len(graph.faces) > 0:
164162
node_to_index = {n: i for i, n in enumerate(graph.node_list)}
165-
face_indices = [[node_to_index[v] for v in face]
166-
for face in graph.faces]
163+
face_indices = [[node_to_index[v] for v in face] for face in graph.faces]
167164
face_maxes = np.array(
168-
[np.max(node_projections[face, :], axis=0)
169-
for face in face_indices]
165+
[np.max(node_projections[face, :], axis=0) for face in face_indices]
170166
)
171167
simplex_projections.append(face_maxes)
172168

@@ -192,7 +188,7 @@ def _compute_directional_transform(
192188
num_thresh = thresholds.shape[0]
193189
result = np.empty((num_dir, num_thresh), dtype=dtype)
194190

195-
sorted_projections = []
191+
sorted_projections = List()
196192
for proj in simplex_projections_list:
197193
sorted_proj = np.empty_like(proj)
198194
for i in prange(num_dir):
@@ -202,7 +198,7 @@ def _compute_directional_transform(
202198
for j in prange(num_thresh):
203199
thresh = thresholds[j]
204200
for i in range(num_dir):
205-
simplex_counts_list = []
201+
simplex_counts_list = List()
206202
for k in range(len(sorted_projections)):
207203
projs = sorted_projections[k][:, i]
208204
simplex_counts_list.append(
@@ -212,7 +208,7 @@ def _compute_directional_transform(
212208
return result
213209

214210
@staticmethod
215-
@njit(parallel=True, fastmath=True)
211+
@njit(fastmath=True)
216212
def shape_descriptor(simplex_counts_list):
217213
"""Calculate shape descriptor from simplex counts (Euler characteristic)"""
218214
chi = 0

0 commit comments

Comments
 (0)