Skip to content

Commit 2acdba6

Browse files
committed
Update to SS:GB v10.4.0 (and run pre-commit linting)
1 parent 60c5e1e commit 2acdba6

24 files changed

Lines changed: 1478 additions & 780 deletions

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ extend-ignore =
77
per-file-ignores =
88
suitesparse_graphblas/io/binary.py:C408,
99
suitesparse_graphblas/tests/test_io.py:E721,
10+
# The api package re-exports its submodules for `from suitesparse_graphblas import api`
11+
suitesparse_graphblas/api/__init__.py:F401,

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ repos:
4141
- id: autoflake
4242
args: [--in-place]
4343
- repo: https://github.com/pycqa/isort
44-
rev: 8.0.1
44+
rev: 9.0.0b2
4545
hooks:
4646
- id: isort
4747
- repo: https://github.com/asottile/pyupgrade
@@ -50,7 +50,7 @@ repos:
5050
- id: pyupgrade
5151
args: [--py311-plus]
5252
- repo: https://github.com/psf/black-pre-commit-mirror
53-
rev: 26.3.1
53+
rev: 26.5.1
5454
hooks:
5555
- id: black
5656
- repo: https://github.com/PyCQA/flake8
@@ -89,7 +89,7 @@ repos:
8989
- id: python-no-log-warn
9090
- id: text-unicode-replacement-char
9191
- repo: https://github.com/python-jsonschema/check-jsonschema
92-
rev: 0.37.0
92+
rev: 0.37.4
9393
hooks:
9494
- id: check-dependabot
9595
- id: check-github-workflows

GB_VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10.3.1
1+
10.4.0

suitesparse.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
set -x # echo on
44

55
# parse SuiteSparse version from first argument, a git tag that ends in the version (no leading v)
6-
if [[ $1 =~ refs/tags/([0-9]*\.[0-9]*\.[0-9]*\.beta[0-9]*).*$ ]]; then
6+
if [[ $1 =~ refs/tags/v?([0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+) ]]; then
7+
# Naming used since v10.4.0-beta.1, e.g. "10.4.0-beta.2". Note that callers
8+
# append the psg patch level (".0"), which is not part of the upstream tag.
9+
echo "Beta version detected (X.Y.Z-beta.N)"
10+
VERSION=${BASH_REMATCH[1]}
11+
elif [[ $1 =~ refs/tags/([0-9]*\.[0-9]*\.[0-9]*\.beta[0-9]*).*$ ]]; then
12+
# Older naming, e.g. "8.0.1.beta1"
713
echo "Beta version detected"
814
VERSION=${BASH_REMATCH[1]}
915
elif [[ $1 =~ refs/tags/([0-9]*\.[0-9]*\.[0-9]*)\..*$ ]]; then

suitesparse_graphblas/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,13 @@ def __repr__(self):
309309

310310
burble = burble()
311311

312-
# Backward-compatible re-exports: functional API moved to suitesparse_graphblas.api
313-
from suitesparse_graphblas.api import iterator, matrix, scalar, vector # noqa: E402,F401
314-
from suitesparse_graphblas.api.global_options import ( # noqa: E402,F401
312+
# isort: off
313+
# Backward-compatible re-exports: functional API moved to suitesparse_graphblas.api.
314+
# These must stay at the bottom of the file: the api modules import names defined
315+
# above (`check_status`, `ffi`, `lib`), so letting isort's `float_to_top` hoist them
316+
# to the top would make `import suitesparse_graphblas` a circular import.
317+
from suitesparse_graphblas.api import iterator, matrix, scalar, vector # noqa: E402, F401
318+
from suitesparse_graphblas.api.global_options import ( # noqa: E402, F401
315319
global_option_get_char,
316320
global_option_get_fp64,
317321
global_option_get_int32,

suitesparse_graphblas/api/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
Guide](https://github.com/DrTimothyAldenDavis/GraphBLAS/blob/stable/Doc/GraphBLAS_UserGuide.pdf)
2121
2222
"""
23+
24+
from suitesparse_graphblas.api import io # noqa: F401
2325
from suitesparse_graphblas.api import (
2426
binaryop,
2527
container,
@@ -33,9 +35,8 @@
3335
matrix,
3436
monoid,
3537
scalar,
36-
semiring,
3738
selectop,
39+
semiring,
3840
unaryop,
3941
vector,
4042
)
41-
from suitesparse_graphblas.api import io # noqa: F401

suitesparse_graphblas/api/binaryop.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,15 @@ def binaryop_print(op, name="", level=lib.GxB_COMPLETE):
104104
True
105105
106106
"""
107-
check_status(op, lib.GxB_BinaryOp_fprint(
108-
op[0], name.encode() if isinstance(name, str) else name,
109-
level, ffi.NULL,
110-
))
107+
check_status(
108+
op,
109+
lib.GxB_BinaryOp_fprint(
110+
op[0],
111+
name.encode() if isinstance(name, str) else name,
112+
level,
113+
ffi.NULL,
114+
),
115+
)
111116

112117

113118
def binaryop_fprint(op, f, name="", level=lib.GxB_COMPLETE):
@@ -122,10 +127,15 @@ def binaryop_fprint(op, f, name="", level=lib.GxB_COMPLETE):
122127
True
123128
124129
"""
125-
check_status(op, lib.GxB_BinaryOp_fprint(
126-
op[0], name.encode() if isinstance(name, str) else name,
127-
level, f,
128-
))
130+
check_status(
131+
op,
132+
lib.GxB_BinaryOp_fprint(
133+
op[0],
134+
name.encode() if isinstance(name, str) else name,
135+
level,
136+
f,
137+
),
138+
)
129139

130140

131141
# ---------------------------------------------------------------------------

suitesparse_graphblas/api/context.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,15 @@ def context_print(ctx, name="", level=lib.GxB_COMPLETE):
201201
True
202202
203203
"""
204-
check_status(ctx, lib.GxB_Context_fprint(
205-
ctx[0], name.encode() if isinstance(name, str) else name,
206-
level, ffi.NULL,
207-
))
204+
check_status(
205+
ctx,
206+
lib.GxB_Context_fprint(
207+
ctx[0],
208+
name.encode() if isinstance(name, str) else name,
209+
level,
210+
ffi.NULL,
211+
),
212+
)
208213

209214

210215
def context_fprint(ctx, f, name="", level=lib.GxB_COMPLETE):
@@ -219,7 +224,12 @@ def context_fprint(ctx, f, name="", level=lib.GxB_COMPLETE):
219224
True
220225
221226
"""
222-
check_status(ctx, lib.GxB_Context_fprint(
223-
ctx[0], name.encode() if isinstance(name, str) else name,
224-
level, f,
225-
))
227+
check_status(
228+
ctx,
229+
lib.GxB_Context_fprint(
230+
ctx[0],
231+
name.encode() if isinstance(name, str) else name,
232+
level,
233+
f,
234+
),
235+
)

suitesparse_graphblas/api/descriptor.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ def descriptor_print(desc, name="", level=lib.GxB_COMPLETE):
2424
True
2525
2626
"""
27-
check_status(desc, lib.GxB_Descriptor_fprint(
28-
desc, name.encode() if isinstance(name, str) else name,
29-
level, ffi.NULL,
30-
))
27+
check_status(
28+
desc,
29+
lib.GxB_Descriptor_fprint(
30+
desc,
31+
name.encode() if isinstance(name, str) else name,
32+
level,
33+
ffi.NULL,
34+
),
35+
)
3136

3237

3338
def descriptor_fprint(desc, f, name="", level=lib.GxB_COMPLETE):
@@ -41,10 +46,15 @@ def descriptor_fprint(desc, f, name="", level=lib.GxB_COMPLETE):
4146
True
4247
4348
"""
44-
check_status(desc, lib.GxB_Descriptor_fprint(
45-
desc, name.encode() if isinstance(name, str) else name,
46-
level, f,
47-
))
49+
check_status(
50+
desc,
51+
lib.GxB_Descriptor_fprint(
52+
desc,
53+
name.encode() if isinstance(name, str) else name,
54+
level,
55+
f,
56+
),
57+
)
4858

4959

5060
# ---------------------------------------------------------------------------
@@ -72,9 +82,14 @@ def descriptor_set_int32(desc, field, value):
7282
False
7383
7484
"""
75-
check_status(desc, lib.GrB_Descriptor_set_INT32(
76-
desc, ffi.cast("int32_t", value), field,
77-
))
85+
check_status(
86+
desc,
87+
lib.GrB_Descriptor_set_INT32(
88+
desc,
89+
ffi.cast("int32_t", value),
90+
field,
91+
),
92+
)
7893

7994

8095
def descriptor_get_size(desc, field):

suitesparse_graphblas/api/examples/bfs.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,29 +95,44 @@ def bfs(A, src, compute_level=True, compute_parent=True):
9595
if compute_level:
9696
scalar.set_int64(level_scalar, current_level)
9797
vector.vector_assign_scalar(
98-
level_vec, level_scalar, lib.GrB_ALL, n,
99-
mask=frontier, desc=lib.GrB_DESC_S,
98+
level_vec,
99+
level_scalar,
100+
lib.GrB_ALL,
101+
n,
102+
mask=frontier,
103+
desc=lib.GrB_DESC_S,
100104
)
101105

102106
if compute_parent:
103107
# Record parent IDs: parent<s(frontier)> = frontier
104108
vector.vector_assign(
105-
parent_vec, frontier, lib.GrB_ALL, n,
106-
mask=frontier, desc=lib.GrB_DESC_S,
109+
parent_vec,
110+
frontier,
111+
lib.GrB_ALL,
112+
n,
113+
mask=frontier,
114+
desc=lib.GrB_DESC_S,
107115
)
108116
# Convert frontier values to their own indices (ROWINDEX).
109117
# After this, frontier(i) == i for every stored entry,
110118
# so the next vxm propagates node i as the parent ID.
111119
vector.vector_apply_indexop(
112-
frontier, lib.GrB_ROWINDEX_INT64, frontier, index_thunk,
120+
frontier,
121+
lib.GrB_ROWINDEX_INT64,
122+
frontier,
123+
index_thunk,
113124
)
114125

115126
current_level += 1
116127

117128
# Expand frontier: frontier<!mask> = frontier * A
118129
vector.vector_vxm(
119-
frontier, semiring, frontier, A,
120-
mask=mask, desc=lib.GrB_DESC_RSC,
130+
frontier,
131+
semiring,
132+
frontier,
133+
A,
134+
mask=mask,
135+
desc=lib.GrB_DESC_RSC,
121136
)
122137

123138
# Stop when the frontier is empty.

0 commit comments

Comments
 (0)