GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Check that imported values have an element for every entry by eriknw · Pull Request #643 · python-graphblas/python-graphblas

Conversation

@eriknw

@eriknw eriknw commented Oct 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

SuiteSparse:GraphBLAS before 10.5.2 checked the size of an imported values buffer in the
wrong units: GB_import compared a count of entries (nvals, or vlen * vdim for bitmap and
full) with Ax_memsize, which is in bytes. So any buffer of at least nvals bytes was
accepted, and later reads ran past its end:

Vector.ss.import_full(values=np.ones(3), size=5)

returned a Vector whose last two values were heap garbage, and so did values too short for a
sub-array dtype:

Vector.ss.import_sparse(size=3, indices=[0, 1], values=np.ones(2), dtype="FP64[2]")

10.5.2 fixed that check (SuiteSparse PR #470); there these imports raise InvalidValue with an
empty message.

"Check that imported values have an element for every entry." Every ss import and pack
now checks the values before handing them to GraphBLAS: sparse, bitmap and full Vectors; csr,
csc, hypercsr, hypercsc, bitmapr, bitmapc, fullr and fullc Matrices; and so Matrix.from_dcsr
and from_dcsc on SuiteSparse. They raise

ValueError: values must have 5 or more elements of dtype FP64, not 3

The check is one helper, check_values_size, next to the previous PR's
check_element_shape. It counts what GraphBLAS will read: nvals, indptr[n], the size, or
nrows x ncols. An iso import needs one element. A larger buffer is still accepted. It stays
for SuiteSparse 10.5.2 and later too, for its message ("Note that SuiteSparse:GraphBLAS 10.5.2
checks the size of imported values").

"Fill one element with a scalar in from_dcsr and from_dcsc on SuiteSparse."

  • Matrix.from_dcsr([0, 1], [0, 1, 2], [0, 1], 1.5, "FP64[2]") gave [[1.5, 1.5], [1.5, 1.5]] on suitesparse-vanilla but raised on SuiteSparse. It now broadcasts the scalar to
    one element and imports it iso, as from_csr does.
  • check_values_size also says what is wrong when a scalar does not fill one element of a
    sub-array dtype.
  • Index pointers that give more entries than there are indices are now reported as an indptr
    problem. Before, they asked for that many values; GraphBLAS raises an InvalidValue with no
    message for them.

Tests: test_ss_import_values_size in test_vector.py and test_matrix.py (SuiteSparse only)
covers FP64 and FP64[2]; sparse, bitmap and full formats; an import and a pack; iso imports
given one element; a scalar for a sub-array dtype; and an indptr past the indices. With the
check bypassed, both fail on 10.5.2 too (InvalidValue does not match), so they test this
check, not SuiteSparse's. test_ss_import_export also checks the second half of a stacked
bitmap import. from_dcsr/from_dcsc with a scalar are tested on both backends.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@eriknw
eriknw added this pull request to stack #650 October 19, 2026 07:50
@codecov

codecov Bot commented Oct 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.75%. Comparing base (d9edd77) to head (e464a64).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #643      +/-   ##
==========================================
+ Coverage   98.16%   98.75%   +0.58%     
==========================================
  Files         105      105              
  Lines       30578    30670      +92     
  Branches     3600     3607       +7     
==========================================
+ Hits        30018    30289     +271     
+ Misses        327      245      -82     
+ Partials      233      136      -97     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@eriknw
eriknw force-pushed the 47c-import-values-length branch from d4703df to f11c703 Compare October 19, 2026 07:55
@eriknw
eriknw force-pushed the 47c-import-values-length branch from f11c703 to 2e69171 Compare October 20, 2026 22:28
@eriknw
eriknw force-pushed the 47c-import-values-length branch from 2e69171 to 1e9240e Compare October 21, 2026 04:14
@eriknw
eriknw force-pushed the 47c-import-values-length branch 2 times, most recently from 0e0e155 to f5d2961 Compare October 28, 2026 04:29
@eriknw
eriknw removed this pull request from stack #650 October 28, 2026 04:29
@eriknw
eriknw added this pull request to stack #653 October 28, 2026 04:30
@eriknw
eriknw removed this pull request from stack #653 October 28, 2026 04:31
@eriknw eriknw mentioned this pull request Oct 28, 2026
Fix Scalar infix expressions with a literal operand #654
Merged
@eriknw
eriknw added this pull request to stack #655 October 28, 2026 04:32
@eriknw
eriknw removed this pull request from stack #655 October 28, 2026 04:33
@eriknw
eriknw added this pull request to stack #657 October 28, 2026 04:33
@eriknw
eriknw force-pushed the 47c-import-values-length branch 2 times, most recently from 842d327 to cdfaec6 Compare October 29, 2026 02:01
@eriknw
eriknw force-pushed the 47c-import-values-length branch 2 times, most recently from 4b91734 to a8136c3 Compare November 3, 2026 12:10
@eriknw
eriknw removed this pull request from stack #657 November 3, 2026 16:44
@eriknw
eriknw force-pushed the 47c-import-values-length branch from a8136c3 to 125101d Compare November 3, 2026 16:44
@eriknw
eriknw added this pull request to stack #660 November 3, 2026 16:45
@eriknw
eriknw force-pushed the 47c-import-values-length branch from 125101d to 3d834e2 Compare November 3, 2026 20:07
@eriknw
eriknw removed this pull request from stack #660 November 3, 2026 23:09
@eriknw
eriknw added this pull request to stack #662 November 3, 2026 23:09
@eriknw
eriknw removed this pull request from stack #662 November 3, 2026 23:11
@eriknw
eriknw added this pull request to stack #664 November 3, 2026 23:12
@eriknw
eriknw force-pushed the 47c-import-values-length branch from 3dc1a1e to 40427e0 Compare November 4, 2026 18:59
@eriknw
eriknw removed this pull request from stack #664 November 4, 2026 20:50
@eriknw
eriknw force-pushed the 47c-import-values-length branch from 40427e0 to 2c5dff3 Compare November 4, 2026 20:50
@eriknw
eriknw added this pull request to stack #666 November 4, 2026 20:50
@eriknw
eriknw force-pushed the 47c-import-values-length branch 3 times, most recently from 1a09737 to e023593 Compare November 9, 2026 15:51
@eriknw
eriknw force-pushed the 47c-import-values-length branch 8 times, most recently from df42073 to cb05b74 Compare November 11, 2026 01:58
Base automatically changed from 47b-udt-values-length to main November 11, 2026 03:23
eriknw added 4 commits November 10, 2026 21:23
@eriknw
Check that imported values have an element for every entry
b15647d
SuiteSparse compares the byte size of an imported values buffer with the
number of entries, not with the bytes they need (GB_import.c sets
Ax_memsize_for_non_iso to nvals or vlen * vdim), so any buffer of at least
nvals bytes got through and was read past its end:

    Vector.ss.import_full(values=np.ones(3), size=5)

built a Vector whose last two values were heap garbage, and so did values
too short for a sub-array dtype, as in

    Vector.ss.import_sparse(size=3, indices=[0, 1], values=np.ones(2), dtype="FP64[2]")

Every ss import and pack (sparse, bitmap and full Vectors; csr, csc,
hypercsr, hypercsc, bitmapr, bitmapc, fullr and fullc Matrices, and so
from_dcsr and from_dcsc) now raises

    ValueError: values must have 5 or more elements of dtype FP64, not 3

before handing GraphBLAS the buffer. An iso import needs one element.
@eriknw
Note that SuiteSparse:GraphBLAS 10.5.2 checks the size of imported va…
a38b02b
…lues

SuiteSparse:GraphBLAS 10.5.2 fixed the import size check that
check_values_size works around: GB_import.c compared the byte size of
the values with the number of entries. With check_values_size bypassed,
the five short imports tried (import_full, import_sparse of FP64[2],
import_bitmapr, and two import_csr) now raise InvalidValue with an empty
message on 10.5.2, where 10.5.1 built them from bytes past the end.
check_values_size still runs on every version: older ones need it, and
its ValueError says what is wrong. Its docstring and the comments of
the two test_ss_import_values_size tests now give the versions.
Comments only.
@eriknw
Fill one element with a scalar in from_dcsr and from_dcsc on SuiteSparse
9354092
Matrix.from_dcsr([0, 1], [0, 1, 2], [0, 1], 1.5, "FP64[2]") gave
[[1.5, 1.5], [1.5, 1.5]] without SuiteSparse, and on SuiteSparse raised
"values must have 1 or more elements of dtype FP64[2], not 0": its
SuiteSparse branch imported the scalar as it was, 8 bytes where one
element is 16. It now broadcasts a scalar to one whole element and
imports it iso, as from_csr and from_csc do; the same for from_dcsc.

check_values_size also says what is wrong in two cases it misreported:
- A scalar that does not fill one element of a sub-array dtype, as in
  Vector.ss.import_full(values=1.5, size=3, dtype="FP64[2]",
  is_iso=True): "a scalar does not fill one element of dtype FP64[2], of
  shape (2,)" (it said "not 0").
- Index pointers that give more entries than there are indices, as in
  import_csr(nrows=1, ncols=3, indptr=[0, 2**62], col_indices=[0],
  values=[1.0]): "index pointers give 4611686018427387904 entries, more
  than the number of indices, 1" (it asked for that many values).
  GraphBLAS rejects such an indptr itself, with an InvalidValue and no
  message, so the check comes first.
@eriknw
Say a scalar does not fill an element only when it is shorter than one
e464a64
import_fullr(values=1.5, nrows=2, ncols=2) said "a scalar does not fill
one element of dtype FP64", though 1.5 is a whole FP64 element and the
problem is that four are needed. Keep that message for a scalar shorter
than one element of a sub-array dtype. Found by review (r47abc).
@eriknw
eriknw force-pushed the 47c-import-values-length branch from cb05b74 to e464a64 Compare November 11, 2026 03:23
@eriknw

eriknw commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@eriknw
eriknw merged commit d6b6bbf into main Nov 11, 2026
2 of 4 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@eriknw
eriknw deleted the 47c-import-values-length branch November 11, 2026 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@eriknw
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.