Skip to content

Commit e22b23f

Browse files
authored
Update to SuiteSparse:GraphBLAS 10.0.1 (#139)
1 parent 2e6920e commit e22b23f

7 files changed

+1154
-947
lines changed

.pre-commit-config.yaml

+28-17
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,28 @@
66
# - &flake8_dependencies below needs updated manually
77
fail_fast: true
88
default_language_version:
9-
python: python3
9+
python: python3
1010
repos:
1111
- repo: https://github.com/pre-commit/pre-commit-hooks
1212
rev: v5.0.0
1313
hooks:
1414
- id: check-added-large-files
15+
- id: check-case-conflict
16+
- id: check-merge-conflict
1517
- id: check-ast
1618
- id: check-toml
1719
- id: check-yaml
20+
# - id: check-executables-have-shebangs
21+
- id: check-vcs-permalinks
22+
- id: destroyed-symlinks
23+
- id: detect-private-key
1824
- id: debug-statements
1925
- id: end-of-file-fixer
2026
- id: mixed-line-ending
21-
# - id: trailing-whitespace
27+
args: [--fix=lf]
28+
- id: trailing-whitespace
2229
- repo: https://github.com/abravalheri/validate-pyproject
23-
rev: v0.20.2
30+
rev: v0.24
2431
hooks:
2532
- id: validate-pyproject
2633
name: Validate pyproject.toml
@@ -30,34 +37,29 @@ repos:
3037
- id: autoflake
3138
args: [--in-place]
3239
- repo: https://github.com/pycqa/isort
33-
rev: 5.13.2
40+
rev: 6.0.1
3441
hooks:
3542
- id: isort
3643
- repo: https://github.com/asottile/pyupgrade
37-
rev: v3.18.0
44+
rev: v3.19.1
3845
hooks:
3946
- id: pyupgrade
4047
args: [--py39-plus]
41-
# - repo: https://github.com/MarcoGorelli/auto-walrus
42-
# rev: v0.2.2
43-
# hooks:
44-
# - id: auto-walrus
45-
# args: [--line-length, "100"]
4648
- repo: https://github.com/psf/black
47-
rev: 24.10.0
49+
rev: 25.1.0
4850
hooks:
4951
- id: black
50-
# - id: black-jupyter
5152
- repo: https://github.com/PyCQA/flake8
52-
rev: 7.1.1
53+
rev: 7.1.2
5354
hooks:
5455
- id: flake8
56+
args: ["--config=.flake8"]
5557
additional_dependencies: &flake8_dependencies
5658
# These versions need updated manually
57-
- flake8==7.1.1
58-
- flake8-comprehensions==3.15.0
59-
- flake8-bugbear==24.8.19
60-
# - flake8-simplify==0.20.0
59+
- flake8==7.1.2
60+
- flake8-comprehensions==3.16.0
61+
- flake8-bugbear==24.12.12
62+
# - flake8-simplify==0.21.0
6163
- repo: https://github.com/asottile/yesqa
6264
rev: v1.5.0
6365
hooks:
@@ -70,6 +72,15 @@ repos:
7072
# hooks:
7173
# - id: pyroma
7274
# args: [-n, "10", .]
75+
- repo: https://github.com/python-jsonschema/check-jsonschema
76+
rev: 0.31.3
77+
hooks:
78+
- id: check-dependabot
79+
- id: check-github-workflows
80+
- repo: meta
81+
hooks:
82+
- id: check-hooks-apply
83+
- id: check-useless-excludes
7384
- repo: https://github.com/pre-commit/pre-commit-hooks
7485
rev: v5.0.0
7586
hooks:

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ COPY --from=suitesparse /build/pycparser/utils/fake_libc_include/* /usr/local/li
2828

2929
RUN apt-get update && apt-get install -yq build-essential git
3030
RUN pip3 install numpy cffi pytest cython
31-
31+
3232
RUN mkdir -p /psg
3333
ADD . /psg
3434

GB_VERSION.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9.4.5
1+
10.0.1

docker_build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if [ $# -eq 0 ]
44
55
Example: ./docker_build.sh v5.1.3 5.1.3.1 main clone push
66
7-
If location is clone then a fresh git clone will be used.
7+
If location is clone then a fresh git clone will be used.
88
If push is provided then the script will attempt to push to dockerhub."
99
exit 1
1010
fi
@@ -27,7 +27,7 @@ then
2727
fi
2828
trap "exit 1" HUP INT PIPE QUIT TERM
2929
trap 'rm -rf "$TMPDIR"' EXIT
30-
30+
3131
cd $TMPDIR
3232
git clone --branch $BRANCH https://github.com/GraphBLAS/python-suitesparse-graphblas.git
3333
cd python-suitesparse-graphblas

suitesparse_graphblas/create_headers.py

+52
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def groupby(index, seq):
5656
AUTO = "/* This file is automatically generated */"
5757

5858
DEPRECATED = {
59+
# Strongly deprecated in SuiteSparse:GraphBLAS 10; will be removed in 11
60+
"GrB_Field",
5961
# enums
6062
"GxB_IS_HYPER",
6163
"GrB_SCMP",
@@ -298,6 +300,7 @@ def groupby(index, seq):
298300
"GxB_COMPRESSION_LZ4HC",
299301
"GxB_COMPRESSION_ZSTD",
300302
"GxB_COMPRESSION_NONE",
303+
"GxB_USE_VALUES",
301304
}
302305

303306
CHAR_DEFINES = {
@@ -354,6 +357,22 @@ def visit_Typedef(self, node):
354357
return rv
355358

356359

360+
class VisitStruct(c_generator.CGenerator):
361+
def __init__(self, *args, **kwargs):
362+
super().__init__(*args, **kwargs)
363+
self.results = []
364+
365+
def visit_Struct(self, node):
366+
rv = super().visit_Struct(node)
367+
if (
368+
("GxB_" in node.name or "GrB_" in node.name)
369+
and "_struct" in node.name
370+
and node.decls is not None
371+
):
372+
self.results.append(rv + ";")
373+
return rv
374+
375+
357376
def get_ast(filename):
358377
fake_include = os.path.dirname(pycparser.__file__) + "utils/fake_libc_include"
359378
ast = parse_file(filename, cpp_args=f"-I{fake_include}")
@@ -428,6 +447,21 @@ def get_groups(ast):
428447
seen.update(val.splitlines())
429448
groups["GxB typedef enums"] = sorted(vals, key=lambda x: sort_key(x.rsplit("}", 1)[-1]))
430449

450+
g = VisitStruct()
451+
_ = g.visit(ast)
452+
structs = g.results
453+
454+
# No non-opaque GrB structs yet
455+
# vals = {x for x in structs if "struct GrB" in x}
456+
# for val in vals:
457+
# seen.update(val.splitlines())
458+
# groups["GrB struct"] = sorted(vals)
459+
460+
vals = {x for x in structs if "struct GxB" in x}
461+
for val in vals:
462+
seen.update(val.splitlines())
463+
groups["GxB struct"] = sorted(vals)
464+
431465
missing_enums = set(enums) - set(groups["GrB typedef enums"]) - set(groups["GxB typedef enums"])
432466
missing_enums = {x for x in missing_enums if not any(y in x for y in IGNORE_ENUMS)}
433467
assert not missing_enums, ", ".join(sorted(missing_enums))
@@ -581,6 +615,12 @@ def handle_typedef_funcs(group):
581615

582616
rv["GxB typedef funcs"] = list(handle_typedef_funcs(groups["GxB typedef funcs"]))
583617

618+
def handle_structs(group):
619+
for text in group:
620+
yield {"text": text}
621+
622+
rv["GxB struct"] = list(handle_structs(groups["GxB struct"]))
623+
584624
class FuncDeclVisitor(c_ast.NodeVisitor):
585625
def __init__(self):
586626
self.functions = []
@@ -628,6 +668,7 @@ def handle_function_node(node):
628668
"IndexBinaryOp": "indexbinary",
629669
"Iterator": "iterator",
630670
"Context": "context",
671+
"Container": "container",
631672
# "everything else" is "core"
632673
"getVersion": "core",
633674
"Global": "core",
@@ -655,6 +696,13 @@ def handle_function_node(node):
655696
len(grb_nodes),
656697
len(groups["GrB methods"]),
657698
)
699+
700+
# Temporary hack for v10.0.1, which duplicates `GxB_Serialized_get_Scalar`
701+
temp_seen = set()
702+
gxb_nodes = [
703+
temp_seen.add(node.name) or node for node in gxb_nodes if node.name not in temp_seen
704+
]
705+
658706
assert len(gxb_nodes) == len(groups["GxB methods"]), (
659707
len(gxb_nodes),
660708
len(groups["GxB methods"]),
@@ -701,6 +749,10 @@ def create_header_text(groups, *, char_defines=None, defines=None):
701749
for group in groups["GxB typedef funcs"]:
702750
text.append(group["text"])
703751
text.append("")
752+
text.append("/* GxB structs */")
753+
for group in groups["GxB struct"]:
754+
text.append(group["text"])
755+
text.append("")
704756
text.append("/* GrB enums */")
705757
for group in groups["GrB typedef enums"]:
706758
text.append(group["text"])

0 commit comments

Comments
 (0)