Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd45197

Browse files
authored
Backport many of the SS:GB 8 changes to run on 7 (python-graphblas#478)
* Backport many of the SS:GB 8 changes to run on 7 * Make fast_matrix_market <1.7 and scipy >=1.11 play nicely together * fix mmread to handle sparse and dense arrays
1 parent 6bbf0cd commit cd45197

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+408
-177
lines changed

.github/workflows/imports.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,7 @@ jobs:
5454
python-version: ${{ needs.rngs.outputs.pyver }}
5555
# python-version: ${{ matrix.python-version }}
5656
- run: python -m pip install --upgrade pip
57+
# - run: pip install --pre suitesparse-graphblas # Use if we need pre-release
5758
- run: pip install -e .[default]
58-
- run: ./scripts/test_imports.sh
59+
- name: Run test imports
60+
run: ./scripts/test_imports.sh

.github/workflows/publish_pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Check with twine
3636
run: python -m twine check --strict dist/*
3737
- name: Publish to PyPI
38-
uses: pypa/[email protected].6
38+
uses: pypa/[email protected].7
3939
with:
4040
user: __token__
4141
password: ${{ secrets.PYPI_TOKEN }}

.github/workflows/test_and_build.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
shell: bash -l {0}
8686
strategy:
8787
# To "stress test" in CI, set `fail-fast` to `false` and perhaps add more items to `matrix.slowtask`
88-
fail-fast: false # Every service seems super-flaky right now...
88+
fail-fast: true
8989
# The build matrix is [os]x[slowtask] and then randomly chooses [pyver] and [sourcetype].
9090
# This should ensure we'll have full code coverage (i.e., no chance of getting unlucky),
9191
# since we need to run all slow tests on Windows and non-Windoes OSes.
@@ -170,25 +170,25 @@ jobs:
170170
nxver=$(python -c 'import random ; print(random.choice(["=2.7", "=2.8", "=3.0", "=3.1", ""]))')
171171
yamlver=$(python -c 'import random ; print(random.choice(["=5.4", "=6.0", ""]))')
172172
sparsever=$(python -c 'import random ; print(random.choice(["=0.13", "=0.14", ""]))')
173-
fmmver=$(python -c 'import random ; print(random.choice(["=1.4", "=1.5", "=1.6", ""]))')
173+
fmmver=$(python -c 'import random ; print(random.choice(["=1.4", "=1.5", "=1.6", "=1.7", ""]))')
174174
if [[ ${{ startsWith(steps.pyver.outputs.selected, '3.8') }} == true ]]; then
175175
npver=$(python -c 'import random ; print(random.choice(["=1.21", "=1.22", "=1.23", "=1.24", ""]))')
176176
spver=$(python -c 'import random ; print(random.choice(["=1.8", "=1.9", "=1.10", ""]))')
177177
pdver=$(python -c 'import random ; print(random.choice(["=1.2", "=1.3", "=1.4", "=1.5", "=2.0", ""]))')
178178
akver=$(python -c 'import random ; print(random.choice(["=1.9", "=1.10", "=2.0", "=2.1", "=2.2", ""]))')
179179
elif [[ ${{ startsWith(steps.pyver.outputs.selected, '3.9') }} == true ]]; then
180180
npver=$(python -c 'import random ; print(random.choice(["=1.21", "=1.22", "=1.23", "=1.24", "=1.25", ""]))')
181-
spver=$(python -c 'import random ; print(random.choice(["=1.8", "=1.9", "=1.10", ""]))')
181+
spver=$(python -c 'import random ; print(random.choice(["=1.8", "=1.9", "=1.10", "=1.11", ""]))')
182182
pdver=$(python -c 'import random ; print(random.choice(["=1.2", "=1.3", "=1.4", "=1.5", "=2.0", ""]))')
183183
akver=$(python -c 'import random ; print(random.choice(["=1.9", "=1.10", "=2.0", "=2.1", "=2.2", ""]))')
184184
elif [[ ${{ startsWith(steps.pyver.outputs.selected, '3.10') }} == true ]]; then
185185
npver=$(python -c 'import random ; print(random.choice(["=1.21", "=1.22", "=1.23", "=1.24", "=1.25", ""]))')
186-
spver=$(python -c 'import random ; print(random.choice(["=1.8", "=1.9", "=1.10", ""]))')
186+
spver=$(python -c 'import random ; print(random.choice(["=1.8", "=1.9", "=1.10", "=1.11", ""]))')
187187
pdver=$(python -c 'import random ; print(random.choice(["=1.3", "=1.4", "=1.5", "=2.0", ""]))')
188188
akver=$(python -c 'import random ; print(random.choice(["=1.9", "=1.10", "=2.0", "=2.1", "=2.2", ""]))')
189189
else # Python 3.11
190190
npver=$(python -c 'import random ; print(random.choice(["=1.23", "=1.24", "=1.25", ""]))')
191-
spver=$(python -c 'import random ; print(random.choice(["=1.9", "=1.10", ""]))')
191+
spver=$(python -c 'import random ; print(random.choice(["=1.9", "=1.10", "=1.11", ""]))')
192192
pdver=$(python -c 'import random ; print(random.choice(["=1.5", "=2.0", ""]))')
193193
akver=$(python -c 'import random ; print(random.choice(["=1.10", "=2.0", "=2.1", "=2.2", ""]))')
194194
fi
@@ -204,20 +204,20 @@ jobs:
204204
# But, it's still useful for us to test with different versions!
205205
psg=""
206206
if [[ ${{ steps.sourcetype.outputs.selected}} == "conda-forge" ]] ; then
207-
psgver=$(python -c 'import random ; print(random.choice(["=7.4.0", "=7.4.1", "=7.4.2", "=7.4.3.0", "=7.4.3.1", "=7.4.3.2", ""]))')
207+
psgver=$(python -c 'import random ; print(random.choice(["=7.4.0", "=7.4.1", "=7.4.2", "=7.4.3.0", "=7.4.3.1", "=7.4.3.2"]))')
208208
psg=python-suitesparse-graphblas${psgver}
209209
elif [[ ${{ steps.sourcetype.outputs.selected}} == "wheel" ]] ; then
210-
psgver=$(python -c 'import random ; print(random.choice(["==7.4.3.2", ""]))')
210+
psgver=$(python -c 'import random ; print(random.choice(["==7.4.3.2"]))')
211211
elif [[ ${{ steps.sourcetype.outputs.selected}} == "source" ]] ; then
212212
# These should be exact versions
213-
psgver=$(python -c 'import random ; print(random.choice(["==7.4.0.0", "==7.4.1.0", "==7.4.2.0", "==7.4.3.0", "==7.4.3.1", "==7.4.3.2", ""]))')
213+
psgver=$(python -c 'import random ; print(random.choice(["==7.4.0.0", "==7.4.1.0", "==7.4.2.0", "==7.4.3.0", "==7.4.3.1", "==7.4.3.2"]))')
214214
else
215215
psgver=""
216216
fi
217217
if [[ ${npver} == "=1.25" ]] ; then
218218
numbaver=""
219219
if [[ ${spver} == "=1.8" ]] ; then
220-
spver=$(python -c 'import random ; print(random.choice(["=1.9", "=1.10", ""]))')
220+
spver=$(python -c 'import random ; print(random.choice(["=1.9", "=1.10", "=1.11", ""]))')
221221
fi
222222
elif [[ ${npver} == "=1.24" || ${{ startsWith(steps.pyver.outputs.selected, '3.11') }} == true ]] ; then
223223
numbaver=$(python -c 'import random ; print(random.choice(["=0.57", ""]))')
@@ -374,6 +374,9 @@ jobs:
374374
# Tests lazy loading of lib, ffi, and NULL in gb.core
375375
echo "from graphblas.core import base" > script.py
376376
coverage run -a script.py
377+
# Test another code pathway for loading lib
378+
echo "from graphblas.core import lib" > script.py
379+
coverage run -a script.py
377380
rm script.py
378381
# Tests whose coverage depend on order of tests :/
379382
# TODO: understand why these are order-dependent and try to fix

.pre-commit-config.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121
- id: check-added-large-files
2222
- id: check-case-conflict
2323
- id: check-merge-conflict
24-
- id: check-symlinks
24+
# - id: check-symlinks
2525
- id: check-ast
2626
- id: check-toml
2727
- id: check-yaml
@@ -39,7 +39,7 @@ repos:
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.1.1
42+
rev: v2.2.0
4343
hooks:
4444
- id: autoflake
4545
args: [--in-place]
@@ -51,7 +51,7 @@ repos:
5151
- id: isort
5252
# Let's keep `pyupgrade` even though `ruff --fix` probably does most of it
5353
- repo: https://github.com/asottile/pyupgrade
54-
rev: v3.4.0
54+
rev: v3.7.0
5555
hooks:
5656
- id: pyupgrade
5757
args: [--py38-plus]
@@ -66,7 +66,7 @@ repos:
6666
- id: black
6767
- id: black-jupyter
6868
- repo: https://github.com/charliermarsh/ruff-pre-commit
69-
rev: v0.0.270
69+
rev: v0.0.275
7070
hooks:
7171
- id: ruff
7272
args: [--fix-only, --show-fixes]
@@ -79,22 +79,22 @@ repos:
7979
additional_dependencies: &flake8_dependencies
8080
# These versions need updated manually
8181
- flake8==6.0.0
82-
- flake8-bugbear==23.5.9
82+
- flake8-bugbear==23.6.5
8383
- flake8-simplify==0.20.0
8484
- repo: https://github.com/asottile/yesqa
85-
rev: v1.4.0
85+
rev: v1.5.0
8686
hooks:
8787
- id: yesqa
8888
additional_dependencies: *flake8_dependencies
8989
- repo: https://github.com/codespell-project/codespell
90-
rev: v2.2.4
90+
rev: v2.2.5
9191
hooks:
9292
- id: codespell
9393
types_or: [python, rst, markdown]
9494
additional_dependencies: [tomli]
9595
files: ^(graphblas|docs)/
9696
- repo: https://github.com/charliermarsh/ruff-pre-commit
97-
rev: v0.0.270
97+
rev: v0.0.275
9898
hooks:
9999
- id: ruff
100100
- repo: https://github.com/sphinx-contrib/sphinx-lint

docs/env.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88
# python-graphblas dependencies
99
- donfig
1010
- numba
11-
- python-suitesparse-graphblas>=7.4.0.0
11+
- python-suitesparse-graphblas>=7.4.0.0,<8
1212
- pyyaml
1313
# extra dependencies
1414
- matplotlib

graphblas/binary/ss.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
from ..core import operator
22

3+
_delayed = {}
4+
35
del operator

graphblas/core/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def _update(self, expr, mask=None, accum=None, replace=False, input_mask=None, *
348348
return
349349
if opts:
350350
# Ignore opts for now
351-
descriptor_lookup(**opts)
351+
desc = descriptor_lookup(**opts)
352352
self.value = expr
353353
return
354354

@@ -371,7 +371,7 @@ def _update(self, expr, mask=None, accum=None, replace=False, input_mask=None, *
371371
else:
372372
if opts:
373373
# Ignore opts for now
374-
descriptor_lookup(**opts)
374+
desc = descriptor_lookup(**opts)
375375
self.value = expr
376376
return
377377
else:
@@ -571,7 +571,7 @@ def _new(self, dtype, mask, name, is_cscalar=None, **opts):
571571
):
572572
if opts:
573573
# Ignore opts for now
574-
descriptor_lookup(**opts)
574+
desc = descriptor_lookup(**opts) # noqa: F841 (keep desc in scope for context)
575575
if self._is_scalar and self._value._is_cscalar != is_cscalar:
576576
return self._value.dup(is_cscalar=is_cscalar, name=name)
577577
rv = self._value

graphblas/core/descriptor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def __init__(
2626
self.mask_structure = mask_structure
2727
self.transpose_first = transpose_first
2828
self.transpose_second = transpose_second
29+
self._context = None # Used by SuiteSparse:GraphBLAS 8
2930

3031
@property
3132
def _carg(self):

graphblas/core/expr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def _setitem(self, resolved_indexes, obj, *, is_submask):
421421
# Fast path using assignElement
422422
if self.opts:
423423
# Ignore opts for now
424-
descriptor_lookup(**self.opts)
424+
desc = descriptor_lookup(**self.opts) # noqa: F841 (keep desc in scope for context)
425425
self.parent._assign_element(resolved_indexes, obj)
426426
else:
427427
mask = self.kwargs.get("mask")

graphblas/core/matrix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ def dup(self, dtype=None, *, clear=False, mask=None, name=None, **opts):
665665
else:
666666
if opts:
667667
# Ignore opts for now
668-
descriptor_lookup(**opts)
668+
desc = descriptor_lookup(**opts) # noqa: F841 (keep desc in scope for context)
669669
new_mat = ffi_new("GrB_Matrix*")
670670
rv = Matrix._from_obj(new_mat, self.dtype, self._nrows, self._ncols, name=name)
671671
call("GrB_Matrix_dup", [_Pointer(rv), self])
@@ -2707,7 +2707,7 @@ def _extract_element(
27072707
result = Scalar(dtype, is_cscalar=is_cscalar, name=name)
27082708
if opts:
27092709
# Ignore opts for now
2710-
descriptor_lookup(**opts)
2710+
desc = descriptor_lookup(**opts) # noqa: F841 (keep desc in scope for context)
27112711
if is_cscalar:
27122712
dtype_name = "UDT" if dtype._is_udt else dtype.name
27132713
if (

0 commit comments

Comments
 (0)