Skip to content

Commit 60e0df1

Browse files
committed
Update to support NetworkX 3.3 (dev), and other maintenance
1 parent 10788fa commit 60e0df1

File tree

16 files changed

+62
-56
lines changed

16 files changed

+62
-56
lines changed

.github/workflows/lint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v4
20-
- uses: actions/setup-python@v4
20+
- uses: actions/setup-python@v5
2121
with:
2222
python-version: "3.10"
23-
- uses: pre-commit/[email protected].0
23+
- uses: pre-commit/[email protected].1

.github/workflows/publish_pypi.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
with:
1919
fetch-depth: 0
2020
- name: Set up Python
21-
uses: actions/setup-python@v4
21+
uses: actions/setup-python@v5
2222
with:
2323
python-version: "3.10"
2424
- name: Install build dependencies
@@ -27,15 +27,15 @@ jobs:
2727
python -m pip install build twine
2828
- name: Build wheel and sdist
2929
run: python -m build --sdist --wheel
30-
- uses: actions/upload-artifact@v3
30+
- uses: actions/upload-artifact@v4
3131
with:
3232
name: releases
3333
path: dist
3434
if-no-files-found: error
3535
- name: Check with twine
3636
run: python -m twine check --strict dist/*
3737
- name: Publish to PyPI
38-
uses: pypa/[email protected].10
38+
uses: pypa/[email protected].11
3939
with:
4040
user: __token__
4141
password: ${{ secrets.PYPI_TOKEN }}

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
with:
2323
fetch-depth: 0
2424
- name: Setup mamba
25-
uses: conda-incubator/setup-miniconda@v2
25+
uses: conda-incubator/setup-miniconda@v3
2626
id: setup_mamba
2727
continue-on-error: true
2828
with:
@@ -35,7 +35,7 @@ jobs:
3535
activate-environment: graphblas
3636
auto-activate-base: false
3737
- name: Setup conda
38-
uses: conda-incubator/setup-miniconda@v2
38+
uses: conda-incubator/setup-miniconda@v3
3939
id: setup_conda
4040
if: steps.setup_mamba.outcome == 'failure'
4141
continue-on-error: false

.pre-commit-config.yaml

+10-10
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@ repos:
3333
- id: name-tests-test
3434
args: ["--pytest-test-first"]
3535
- repo: https://github.com/abravalheri/validate-pyproject
36-
rev: v0.15
36+
rev: v0.16
3737
hooks:
3838
- id: validate-pyproject
3939
name: Validate pyproject.toml
4040
# I don't yet trust ruff to do what autoflake does
4141
- repo: https://github.com/PyCQA/autoflake
42-
rev: v2.2.1
42+
rev: v2.3.0
4343
hooks:
4444
- id: autoflake
4545
args: [--in-place]
4646
- repo: https://github.com/pycqa/isort
47-
rev: 5.13.1
47+
rev: 5.13.2
4848
hooks:
4949
- id: isort
5050
- repo: https://github.com/asottile/pyupgrade
51-
rev: v3.15.0
51+
rev: v3.15.1
5252
hooks:
5353
- id: pyupgrade
5454
args: [--py310-plus]
@@ -58,23 +58,23 @@ repos:
5858
- id: auto-walrus
5959
args: [--line-length, "100"]
6060
- repo: https://github.com/psf/black
61-
rev: 23.12.0
61+
rev: 24.2.0
6262
hooks:
6363
- id: black
6464
# - id: black-jupyter
6565
- repo: https://github.com/astral-sh/ruff-pre-commit
66-
rev: v0.1.7
66+
rev: v0.2.2
6767
hooks:
6868
- id: ruff
6969
args: [--fix-only, --show-fixes]
7070
- repo: https://github.com/PyCQA/flake8
71-
rev: 6.1.0
71+
rev: 7.0.0
7272
hooks:
7373
- id: flake8
7474
additional_dependencies: &flake8_dependencies
7575
# These versions need updated manually
76-
- flake8==6.1.0
77-
- flake8-bugbear==23.12.2
76+
- flake8==7.0.0
77+
- flake8-bugbear==24.2.6
7878
- flake8-simplify==0.21.0
7979
- repo: https://github.com/asottile/yesqa
8080
rev: v1.5.0
@@ -89,7 +89,7 @@ repos:
8989
additional_dependencies: [tomli]
9090
files: ^(graphblas_algorithms|docs)/
9191
- repo: https://github.com/astral-sh/ruff-pre-commit
92-
rev: v0.1.7
92+
rev: v0.2.2
9393
hooks:
9494
- id: ruff
9595
# `pyroma` may help keep our package standards up to date if best practices change.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/graphblas-algorithms)](https://pypi.python.org/pypi/graphblas-algorithms/)
66
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/python-graphblas/graphblas-algorithms/blob/main/LICENSE)
77
<br>
8-
[![Tests](https://github.com/python-graphblas/graphblas-algorithms/workflows/Tests/badge.svg?branch=main)](https://github.com/python-graphblas/graphblas-algorithms/actions)
8+
[![Tests](https://github.com/python-graphblas/graphblas-algorithms/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/python-graphblas/graphblas-algorithms/actions)
99
[![Coverage](https://codecov.io/gh/python-graphblas/graphblas-algorithms/branch/main/graph/badge.svg)](https://codecov.io/gh/python-graphblas/graphblas-algorithms)
1010
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7329185.svg)](https://doi.org/10.5281/zenodo.7329185)
1111
[![Discord](https://img.shields.io/badge/Chat-Discord-blue)](https://discord.com/invite/vur45CbwMz)

graphblas_algorithms/algorithms/_bfs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""BFS routines used by other algorithms"""
1+
"""BFS routines used by other algorithms."""
22

33
import numpy as np
44
from graphblas import Matrix, Vector, binary, indexunary, replace, semiring, unary

graphblas_algorithms/algorithms/_helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def normalize(x, how):
1919

2020

2121
def is_converged(xprev, x, tol):
22-
"""Check convergence, L1 norm: err = sum(abs(xprev - x)); err < N * tol
22+
"""Check convergence, L1 norm: ``err = sum(abs(xprev - x)); err < N * tol``.
2323
2424
This modifies `xprev`.
2525
"""

graphblas_algorithms/algorithms/shortest_paths/weighted.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,14 @@ def bellman_ford_path_length(G, source, target):
116116

117117

118118
def bellman_ford_path_lengths(G, nodes=None, *, expand_output=False):
119-
"""Extra parameter: expand_output
119+
"""Extra parameter: expand_output.
120120
121121
Parameters
122122
----------
123123
expand_output : bool, default False
124124
When False, the returned Matrix has one row per node in nodes.
125125
When True, the returned Matrix has the same shape as the input Matrix.
126+
126127
"""
127128
# Same algorithms as in `single_source_bellman_ford_path_length`, but with
128129
# `Cur` as a Matrix with each row corresponding to a source node.

graphblas_algorithms/classes/_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def matrix_to_vectornodemap(self, A):
177177

178178

179179
def matrix_to_dicts(self, A, *, use_row_index=False, use_column_index=False, values_are_keys=False):
180-
"""Convert a Matrix to a dict of dicts of the form ``{row: {col: val}}``
180+
"""Convert a Matrix to a dict of dicts of the form ``{row: {col: val}}``.
181181
182182
Use ``use_row_index=True`` to return the row index as keys in the dict,
183183
and likewise for `use_column_index=True``.
@@ -256,7 +256,7 @@ def _cacheit(self, key, func, *args, **kwargs):
256256

257257

258258
def renumber_key_to_id(self, indices):
259-
"""Create `key_to_id` for e.g. a subgraph with node ids from `indices`"""
259+
"""Create `key_to_id` for e.g. a subgraph with node ids from `indices`."""
260260
id_to_key = self.id_to_key
261261
return {id_to_key[index]: i for i, index in enumerate(indices)}
262262
# Alternative (about the same performance)

graphblas_algorithms/classes/digraph.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323

2424
def get_AT(G, mask=None):
25-
"""A.T"""
25+
"""``A.T``."""
2626
A = G._A
2727
cache = G._cache
2828
if "AT" not in cache:
@@ -31,7 +31,7 @@ def get_AT(G, mask=None):
3131

3232

3333
def get_Up(G, mask=None):
34-
"""select.triu(A)"""
34+
"""``select.triu(A)``."""
3535
A = G._A
3636
cache = G._cache
3737
if "U+" not in cache:
@@ -50,7 +50,7 @@ def get_Up(G, mask=None):
5050

5151

5252
def get_Lp(G, mask=None):
53-
"""select.tril(A)"""
53+
"""``select.tril(A)``."""
5454
A = G._A
5555
cache = G._cache
5656
if "L+" not in cache:
@@ -69,7 +69,7 @@ def get_Lp(G, mask=None):
6969

7070

7171
def get_Um(G, mask=None):
72-
"""select.triu(A, 1)"""
72+
"""``select.triu(A, 1)``."""
7373
A = G._A
7474
cache = G._cache
7575
if "U-" not in cache:
@@ -93,7 +93,7 @@ def get_Um(G, mask=None):
9393

9494

9595
def get_Lm(G, mask=None):
96-
"""select.tril(A, -1)"""
96+
"""``select.tril(A, -1)``."""
9797
A = G._A
9898
cache = G._cache
9999
if "L-" not in cache:
@@ -117,7 +117,7 @@ def get_Lm(G, mask=None):
117117

118118

119119
def get_recip_degreesp(G, mask=None):
120-
"""pair(A & A.T).reduce_rowwise()"""
120+
"""``pair(A & A.T).reduce_rowwise()``."""
121121
A = G._A
122122
cache = G._cache
123123
AT = cache.get("AT", A.T)
@@ -159,7 +159,7 @@ def get_recip_degreesp(G, mask=None):
159159

160160

161161
def get_recip_degreesm(G, mask=None):
162-
"""C = select.offdiag(A) ; pair(C & C.T).reduce_rowwise()"""
162+
"""``C = select.offdiag(A) ; pair(C & C.T).reduce_rowwise()``."""
163163
A = G._A
164164
cache = G._cache
165165
if "AT" in cache:
@@ -236,7 +236,7 @@ def get_recip_degreesm(G, mask=None):
236236

237237

238238
def get_total_degreesp(G, mask=None):
239-
"""A.reduce_rowwise(agg.count) + A.reduce_columnwise(agg.count)"""
239+
"""``A.reduce_rowwise(agg.count) + A.reduce_columnwise(agg.count)``."""
240240
cache = G._cache
241241
if mask is not None:
242242
if "total_degrees+" in cache:
@@ -266,7 +266,7 @@ def get_total_degreesp(G, mask=None):
266266

267267

268268
def get_total_degreesm(G, mask=None):
269-
"""C = select.offdiag(A) ; C.reduce_rowwise(agg.count) + C.reduce_columnwise(agg.count)"""
269+
"""``C = select.offdiag(A) ; C.reduce_rowwise(agg.count) + C.reduce_columnwise(agg.count)``."""
270270
cache = G._cache
271271
if mask is not None:
272272
if "total_degrees-" in cache:
@@ -296,7 +296,7 @@ def get_total_degreesm(G, mask=None):
296296

297297

298298
def get_total_recipp(G, mask=None):
299-
"""pair(A & A.T).reduce_scalar()"""
299+
"""``pair(A & A.T).reduce_scalar()``."""
300300
A = G._A
301301
cache = G._cache
302302
if "total_recip+" not in cache:
@@ -315,7 +315,7 @@ def get_total_recipp(G, mask=None):
315315

316316

317317
def get_total_recipm(G, mask=None):
318-
"""C = select.offdiag(A) ; pair(C & C.T).reduce_scalar()"""
318+
"""``C = select.offdiag(A) ; pair(C & C.T).reduce_scalar()``."""
319319
cache = G._cache
320320
if "total_recip-" not in cache:
321321
if "total_recip+" in cache and cache.get("has_self_edges") is False:
@@ -330,7 +330,7 @@ def get_total_recipm(G, mask=None):
330330

331331

332332
def has_self_edges(G, mask=None):
333-
"""A.diag().nvals > 0"""
333+
"""``A.diag().nvals > 0``."""
334334
A = G._A
335335
cache = G._cache
336336
if "has_self_edges" not in cache:

graphblas_algorithms/classes/graph.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010

1111

1212
def get_A(G, mask=None):
13-
"""A"""
13+
"""``A``."""
1414
return G._A
1515

1616

1717
def get_AT(G, mask=None):
18-
"""A.T"""
18+
"""``A.T``."""
1919
A = G._A
2020
G._cache["AT"] = A
2121
return A
2222

2323

2424
def get_offdiag(G, mask=None):
25-
"""select.offdiag(A)"""
25+
"""``select.offdiag(A)``."""
2626
A = G._A
2727
cache = G._cache
2828
if "offdiag" not in cache:
@@ -38,7 +38,7 @@ def get_offdiag(G, mask=None):
3838

3939

4040
def get_Up(G, mask=None):
41-
"""select.triu(A)"""
41+
"""``select.triu(A)``."""
4242
A = G._A
4343
cache = G._cache
4444
if "U+" not in cache:
@@ -54,7 +54,7 @@ def get_Up(G, mask=None):
5454

5555

5656
def get_Lp(G, mask=None):
57-
"""select.tril(A)"""
57+
"""``select.tril(A)``."""
5858
A = G._A
5959
cache = G._cache
6060
if "L+" not in cache:
@@ -70,7 +70,7 @@ def get_Lp(G, mask=None):
7070

7171

7272
def get_Um(G, mask=None):
73-
"""select.triu(A, 1)"""
73+
"""``select.triu(A, 1)``."""
7474
A = G._A
7575
cache = G._cache
7676
if "U-" not in cache:
@@ -91,7 +91,7 @@ def get_Um(G, mask=None):
9191

9292

9393
def get_Lm(G, mask=None):
94-
"""select.tril(A, -1)"""
94+
"""``select.tril(A, -1)``."""
9595
A = G._A
9696
cache = G._cache
9797
if "L-" not in cache:
@@ -112,7 +112,7 @@ def get_Lm(G, mask=None):
112112

113113

114114
def get_diag(G, mask=None):
115-
"""A.diag()"""
115+
"""``A.diag()``."""
116116
A = G._A
117117
cache = G._cache
118118
if "diag" not in cache:
@@ -193,7 +193,7 @@ def has_negative_edgesm(G, mask=None):
193193

194194

195195
def has_self_edges(G, mask=None):
196-
"""A.diag().nvals > 0"""
196+
"""``A.diag().nvals > 0``."""
197197
A = G._A
198198
cache = G._cache
199199
if "has_self_edges" not in cache:

graphblas_algorithms/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@pytest.fixture(scope="session", autouse=True)
55
def ic():
6-
"""Make `ic` available everywhere during testing for easier debugging"""
6+
"""Make `ic` available everywhere during testing for easier debugging."""
77
try:
88
import icecream
99
except ImportError:

graphblas_algorithms/nxapi/_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def normalize_chunksize(chunksize, itemsize=1, N=None):
8888

8989

9090
def partition(chunksize, L, *, evenly=True):
91-
"""Partition a list into chunks"""
91+
"""Partition a list into chunks."""
9292
N = len(L)
9393
if N == 0:
9494
return
@@ -109,7 +109,7 @@ def partition(chunksize, L, *, evenly=True):
109109

110110

111111
def split_evenly(k, L):
112-
"""Split a list into approximately-equal parts"""
112+
"""Split a list into approximately-equal parts."""
113113
N = len(L)
114114
if N == 0:
115115
return

0 commit comments

Comments
 (0)