Repository navigation
Tests: raise coverage of the Python code, and fix what they found - #166
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #166 +/- ##
===========================================
+ Coverage 85.86% 98.79% +12.92%
===========================================
Files 32 42 +10
Lines 2774 4231 +1457
Branches 257 354 +97
===========================================
+ Hits 2382 4180 +1798
+ Misses 250 28 -222
+ Partials 142 23 -119 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
eriknw
marked this pull request as ready for review
November 25, 2026 21:06
eriknw
force-pushed
the
coverage-tests
branch
from
November 26, 2026 00:43
e4afa1b to
140d3d5
Compare
binaryop_get_string, unaryop_get_string, indexunaryop_get_string,
indexbinaryop_get_string and monoid_get_string read the string into
ffi.new("char[256]"), but GrB_*_get_String strcpy the whole string into
the caller's buffer. Any longer string overran the buffer and came back
cut at 256 characters. A name set with set_string has no length limit,
on a monoid as on an operator, and neither has an operator's
GxB_JIT_C_DEFINITION.
Ask GraphBLAS for the size with *_get_SIZE first and allocate that much.
The new tests set a 510-character name on each kind of object and give
each kind of operator a definition of about 600 characters, without the
JIT, which only reads it. Before the fix, all nine returned only the
first 256 characters.
monoid_identity and monoid_terminal hand GxB_Monoid_identity and GxB_Monoid_terminal a char[256], and GraphBLAS copies one value of the monoid's type into it, of the type's full size. A monoid of a user-defined type larger than 256 bytes overran the buffer on the heap, and the caller got back only the first 256 bytes. Find the size from the monoid's operator's output type and allocate that, but never less than the 256 bytes the functions have always returned, so nothing changes for the built-in types. The new test builds an elementwise-max monoid of a 512-byte type, checks its identity and terminal, and reduces a vector with it; before the fix it failed with "assert 256 >= 512" on the length of the returned identity.
The doctests use only built-in operators, so nothing ran the constructors of the operator modules, and indexbinaryop had no test at all, since GraphBLAS has no built-in index binary operator. Make an operator of each kind from a cffi callback and check its types and type codes, then use it: a unary operator in apply, a binary operator in eWiseAdd (it applies only where both inputs have an entry), an index unary operator in apply with a thunk, and an index binary operator, bound to a theta, in eWiseMult. The values depend on the row and column indices, so a mix-up of the index arguments would show. Run each constructor both with garbage collection and with free=None, then free by hand. Named operators check the JIT name and definition from str and from bytes, and print them; they aren't used in an operation, which could start the JIT. Also check that GraphBLAS errors come through as exceptions: a NULL type in a constructor, setting a type code, renaming a built-in, and each select operator function with a NULL operator.
The doctests make one monoid per type, always garbage collected and always from the operator of a known monoid. GraphBLAS ignores the identity and terminal given with such an operator and uses its own, so the doctests can't tell whether the values reach GraphBLAS. Build each typed monoid, with and without a terminal, from FIRST, which isn't a known monoid, with identities and terminals at the ends of the type's range. Read them back, check that an empty vector reduces to the identity, and run each constructor both with garbage collection and with free=None. The large user-defined type's monoid now also goes through monoid_new_udt, and a monoid whose operator has a bool output fails with DomainMismatch.
The doctests extract tuples only from objects that have entries, so nothing took the path for an empty one, and the free=None paths of matrix_new, matrix_dup, vector_new and vector_dup never ran. For each type, extract from an empty matrix and vector and check the dtypes, then build one from values at the ends of the type's range and extract them again. Make and duplicate a matrix and a vector without garbage collection and free them by hand.
The typed functions for FC32 and FC64 are defined under "if supports_complex():", which is always true: the cffi build always declares GraphBLAS.h's complex types (on MSVC through its own complex types). The false branch can't be taken, so coverage reported each check as a partial branch that no test could cover.
Round-trip every type, held by row and by column, in each sparsity, for an empty matrix, a 3x4 matrix with an empty row and column, and iso matrices (sparse and full), which nothing tested. Compare the entries exactly, and compare the format, sparsity status and control, switches and iso flag of the result. Test each opener with a str filename, and check the text header. The tests are added after the existing ones, which they leave alone.
binwrite unpacks the matrix to write its arrays and packs them back,
but packing resets the sparsity control, hyper switch and bitmap switch
to their defaults, so writing a matrix changed its settings (the file
itself had the right ones). This is probably why the round-trip test
has its sparsity-control assertion commented out.
Set them again after packing. The new test, for each sparsity and for
a write that fails, showed before the fix:
{'bitmap_switch': 0.0599...} != {'bitmap_switch': 0.75}
{'sparsity_control': 15} != {'sparsity_control': 8}
{'hyper_switch': 0.0625} != {'hyper_switch': 0.25}
binwrite makes the file's header after unpacking the matrix, but outside
the try/finally that packs the arrays back. So comments that are not
ASCII raised UnicodeEncodeError and left the matrix empty, its arrays
lost. The new test showed, before the fix:
(shapes (0,), (3,) mismatch)
ACTUAL: array([], dtype=uint64)
DESIRED: array([0, 2, 2], dtype=uint64)
Make the header inside the try. The error is still raised, no file is
written, and the matrix is left as it was.
binread checked the length of the arrays it reads, but not of the
header and the fields after it. A short read gave `ffi.from_buffer` too
few bytes, and indexing the result read past the end of them. A file
cut anywhere in its first 600 bytes or so raised AssertionError (the
implementation check), TypeError, or, for a bitmap matrix, returned an
empty 0x0 matrix. Cutting a 701-byte bitmap file at each length gave:
AssertionError: 516, TypeError: 10, returned a matrix: 31, EOFError: 144
Check every read, and raise EOFError as for truncated arrays. The new
test cuts files of each sparsity at every length.
Patch the format and the sparsity status that binwrite wrote, and check that binread rejects each with its TypeError.
The final `else` of the unpacking cases was marked `# pragma nocover`, which the `pragma: no cover` pattern in pyproject.toml does not match. Spell it so, and mark the matching `else` of the packing cases, which can't run because the unpacking cases raised already.
binwrite pads its text header to 512 bytes but doesn't cut it there, so comments of more than about 330 characters make a longer header. binread skips exactly 512 bytes, and the file can't be read: the implementation check fails on the header's text. Whether binwrite should shorten such comments or refuse them is a choice of behavior, so this only marks the test as an expected failure. It passes with either fix, as long as the matrix is left as it was.
Test which compression get_serialize_desc puts on the descriptor (the level is added only for LZ4HC and ZSTD), round-trip matrices and vectors with each compression, and check that the compression and level change the size of the result, so they reach GraphBLAS. Test the `free` argument of deserialize_matrix and deserialize_vector: None or False leaves freeing to the caller, and a callable is called when the result is released. Invalid data raises InvalidObject. `nthreads` doesn't work: serialize sets GxB_NTHREADS on a descriptor, and GraphBLAS 10 has no such descriptor field (the number of threads is a GxB_Context setting), so serialize_matrix and serialize_vector raise InvalidValue whenever it is given. Fixing it means choosing how to use a context, so the test is marked as an expected failure.
Several docstrings disagreed with GraphBLAS's own description of the iterator (in GraphBLAS.h), and with what the functions return: - row_iterator_kount and col_iterator_kount don't count the entries in the current row or column: they give the number of rows (columns) the iterator holds, nrows (ncols) unless the matrix is hypersparse. - row_iterator_kseek and col_iterator_kseek don't seek the k-th entry of the current row: they seek the k-th row (column) held. - next_col and next_row return GrB_NO_VALUE at the end of a row or column, not GxB_EXHAUSTED; seek_row, seek_col, next_row and next_col return GrB_NO_VALUE for an empty row or column. - The attach functions never return GxB_EXHAUSTED; the row and column iterators raise NotImplementedException for the other format. Three doctests used an iterator before seeking it, which GraphBLAS leaves undefined; one showed next_col moving to the next entry, though it had returned GrB_NO_VALUE. Seek first, and show the return codes. Also say what getp and getpmax mean for a bitmap matrix or vector.
Iterate over matrices of each sparsity with the entry, row and column iterators (as GraphBLAS's documentation does), and over vectors, and compare with the entries. Test kount and kseek, including on hypersparse matrices, seeking empty rows and columns, positions in bitmap matrices and vectors, the formats the row and column iterators need, iterator_new's `free` argument, and each type's value getter at the limits of its type.
Set and get each type's limits, check that a getter returns None for a scalar with no value, that the value has the right Python type, that scalar_dup copies it and scalar_clear removes it, and that getters of other types cast. Test the `free` argument of scalar_new and scalar_dup.
check_status picked the exception class with _error_code_lookup[code], which has no entry for GrB_ALREADY_SET, GxB_GPU_ERROR or GxB_OUTPUT_IS_READONLY. GraphBLAS returns GrB_ALREADY_SET when an object's name is set a second time, so calling grb_type_set_string(T, lib.GrB_NAME, ...) twice raised KeyError: -9 instead of a GraphBLAS error. Fall back to the base class, exceptions.GraphBLASException. Giving these codes classes of their own would add public names, so this change doesn't. The new tests pass every GrB_Info code in the header to check_status and set a type's name twice. Before the fix they failed with KeyError -9, -7002 and -7003.
…string
Both read the string into ffi.new("char[256]"), but GrB_Global_get_String
and GrB_Type_get_String strcpy the whole string into the caller's buffer.
Any longer string overran the buffer and came back cut at 256 characters.
Several global strings are always longer: GxB_LIBRARY_LICENSE (614
characters), GxB_API_ABOUT (346). JIT settings can be longer too
(GxB_JIT_C_COMPILER_FLAGS can be 900+), and so can a type's
GxB_JIT_C_DEFINITION.
Ask GraphBLAS for the size with *_get_SIZE first and allocate that much.
The new tests read the two long global strings, set and read back a
1000-character GxB_JIT_C_PREFACE, and read back a type definition longer
than 256 characters. Before the fix, each returned only the first 256
characters.
The docstring shows burble.is_enabled as False and True, and it returned a bool until the update to SuiteSparse:GraphBLAS 7.4.0. That update moved it from GxB_Global_Option_get with a bool* to GxB_Global_Option_get_INT32, which returns the int32 0 or 1. The repr changed with it, to <burble is_enabled=0>. Convert the value to a bool. The new test checks is_enabled with `is`, and checks the repr, before and after enable(). Before the fix it failed with `assert 0 is False`.
The docstring said to write `with burble():`. burble is an instance, not the class, so that raises "TypeError: 'burble' object is not callable". `with burble:` is the form that works. The example's second line also began with ">>>" where a continuation line takes "...". Also close the parenthesis in the three "(has GraphBLAS been initialized?" error messages.
Each one now has a test for its error path (an invalid field raises InvalidValue). Each setter is also checked by setting a new value, reading it back through both the GxB_Global_Option and GrB_Global interfaces, and restoring the old value. GxB_HYPER_SWITCH is also checked as the default that new matrices take. Tests that change a global option are marked thread_unsafe.
- libget: a GrB_ name, one that falls back to GxB_, and one that exists as neither (the AttributeError names what was asked for). - vararg: values pass through variadic GxB_Matrix_Option_set/get and come back right, as a double, an int32 and pointers. On osx-arm64 this goes through the char * cast; elsewhere vararg returns its argument. - The type sets: each holds the GraphBLAS types it should, by name. - burble as a context manager: it prints diagnostics only while enabled, restores the previous state when nested, when already enabled, and when the block raises, and it unpickles as itself. Two branches in __init__.py are marked "no cover": complex_types for a build without complex types (every build uses suitesparse_graphblas.h, which has them), and the failure path of GrB_init/GxB_init, which fail only when GraphBLAS is already initialized (checked just before), on bad arguments, or out of memory.
The script runs in a fresh process, so it can check what happens before GraphBLAS is initialized. burble and the global option getters raise Panic, and so does container_new. An unknown memory_manager raises ValueError and leaves GraphBLAS uninitialized. It now initializes with memory_manager="C", since every pytest session already initializes with the default, "numpy". This also checks that case doesn't matter, and that NumPy's memory is then not handed to GraphBLAS without a copy.
- free=None: the handle isn't freed on collection, works until freed by hand, and is NULL afterwards. Using a freed context raises NullPointer. - Descriptors: a new descriptor's fields and name can be set and read back. A built-in descriptor's fields and name are read-only. - Types and semirings: setting and reading a name, and the errors for a number property read as a string, setting a semiring's type codes, and renaming a built-in semiring. - Contexts: an invalid field raises InvalidValue. container_free's error path is marked "no cover", since GxB_Container_free always returns GrB_SUCCESS.
The doctest covered one path graph in the default mode. The new tests compare levels and parents with a plain-Python BFS on a random directed graph, from two sources, with a bool and an FP64 adjacency matrix, in all three modes (level and parent, level only, parent only). They also check that the parent is the lowest-numbered one, an isolated source, and the error when neither output is asked for. The script's __main__ block is run with runpy, with initialize stubbed out since the session has already initialized GraphBLAS, and its table is checked.
The test meant to fill every entry when it asks for GxB_FULL, but it compared the type with the sparsity constant (`T is not lib.GxB_FULL`), which is always true. So every matrix got the same single entry, and GraphBLAS can't make a 2x2 matrix with one entry full: binwrite never wrote FULLR or FULLC, and binread never read them. The branch it skipped called lib.GrB_assign, which cffi doesn't have, since GrB_assign is a C _Generic macro. Test the sparsity, and fill every entry with the type's element setter. Also check that A has the requested format before writing it, and that B has it after reading it back, so that a test that writes the wrong format can't pass again.
The doctest helper never closed its duplicate of fd 1, so it leaked one file descriptor per call. If the call raised, fd 1 stayed pointed at the pipe for the rest of the process, so later output went into a pipe that nothing read, and the process would block once the pipe filled. A failing print doctest would then hide its own failure, and could hang the test run. Restore fd 1 and close every descriptor in finally blocks. The new tests capture a context's print three times and print a freed context (which raises NullPointer), and check that fd 1 is the same file afterwards and that the next free descriptors haven't changed. Before the fix the first test failed with [11, 12, 16, ...] == [11, 12, 13, ...], and the second found fd 1 still pointing at the pipe.
The assertion was commented out because binwrite reset the matrix's sparsity control when it packed the matrix back. binwrite now restores it, so the round trip keeps it.
descriptor_get_string and semiring_get_string read into
ffi.new("char[256]"), but GrB_Descriptor_get_String and
GrB_Semiring_get_String strcpy the whole string into the caller's
buffer. A name set with GrB_NAME has no length limit (GB_user_name_set
allocates strlen + 1; GxB_MAX_NAME_LEN bounds only the JIT C name), so a
name longer than 255 characters overran the buffer and came back cut at
256 characters.
Ask GraphBLAS for the size first, as global_get_string and
grb_type_get_string now do. The new tests set a 1000-character name on a
descriptor and on a semiring and read it back. Before the fix both came
back as the first 256 characters.
One change follows from GraphBLAS itself: GrB_Descriptor_get_String
returns the name whatever the field, but GrB_Descriptor_get_SIZE accepts
only GrB_NAME. So descriptor_get_string now raises InvalidValue for any
other field, as the other string getters do, instead of returning the
name.
Emscripten's pipes don't report end-of-file. Once the write end is closed, reading an empty pipe raises BlockingIOError (EAGAIN) instead of returning b"", even though the read end is blocking. So on Pyodide, _capture_c_output raised whenever the call printed nothing. The existing doctests always print something, so none of them hit it. Treat BlockingIOError from the read as no output. The new test captures a call that prints nothing. On Pyodide 314.0.7 it failed with "BlockingIOError: [Errno 6] Resource temporarily unavailable" before the fix, and so did the burble test that checks that nothing is printed while burble is off. Elsewhere the read returns b"" as before, so the new branch is marked "no cover".
If os.dup2(w, 1) raised, the write end of the pipe was never closed: only the inner finally closed it, and that runs only once the redirect has worked.
The size is asked for first now, so an invalid field fails in GrB_Global_get_SIZE, but the message still said GrB_Global_get_String.
check_status already falls back to GraphBLASException. The three burble methods still indexed _error_code_lookup directly, so a code with no class raised KeyError.
…r fields It ignores the field and returns the name, which is "" when none is set, not the name in every case.
CI's macOS jobs (conda-forge, arm64) failed it: the double set through vararg read back as 0.0. conda-forge's cffi links conda's libffi, and through it a variadic call on macOS arm64 loses its variadic arguments, with or without vararg: an int32 setting doesn't change either (reproduced with cffi 2.0.0 and libffi 3.5.2). PyPI's cffi links the system libffi, and the test passes with it (cffi 2.0.0 and 2.1.1), so the wheel jobs still run it for real.
As in matrix, vector and monoid: the build always declares the complex types, so supports_complex() is never false and its false branch only shows as a partial.
eriknw
force-pushed
the
coverage-tests
branch
from
November 26, 2026 01:32
140d3d5 to
0c560f0
Compare
Member
Author
|
This mostly adds fixes in |
check_status had no class for GrB_ALREADY_SET, GxB_GPU_ERROR or GxB_OUTPUT_IS_READONLY, so they raised the GraphBLASException base class. Give each its own subclass, as for every other GrB_Info code: - GrB_ALREADY_SET: GrB_NAME of a type, operator, monoid or semiring, or a JIT C name or definition, set a second time. - GxB_OUTPUT_IS_READONLY: writing to an object whose memory is read-only, such as a vector loaded with GxB_IS_READONLY. - GxB_GPU_ERROR: CUDA builds. A code a newer GraphBLAS adds still falls back to GraphBLASException, and the test of every GrB_Info code now fails until such a code has a class.
…'s table check_status looks up the object's *_error function by its C type to get GraphBLAS's error string. An object type missing from _error_func_lookup raises TypeError instead of the GraphBLAS exception. Derive the expected types from the signatures of every *_error function the build declares, so a new object type in a newer GraphBLAS fails the test.
The package has code for builds without complex types (supports_complex() and its `if supports_complex():` blocks), but nothing has built that way since the MSVC build switched to _Fcomplex and _Dcomplex, so none of it is tested. SuiteSparse:GraphBLAS can't be built without complex types: its CMake stops if the compiler has neither C99 nor MSVC complex numbers, and GraphBLAS.h has an #error for that case (GxB_NO_FC32 and GxB_NO_FC64 only drop factory kernels). So leave them out on this side instead: with the variable set, cffi declares suitesparse_graphblas_no_complex.h, which create_headers.py keeps current, instead of suitesparse_graphblas.h, and links the same library.
_ss_typecodes and _ss_typenames used lib.GxB_FC32 and lib.GxB_FC64
unconditionally, so in a build without complex types, importing
suitesparse_graphblas.io raised AttributeError. Built with
SUITESPARSE_GRAPHBLAS_NO_COMPLEX=1, pytest failed to collect test_io.py,
io/__init__.py and binary.py:
AttributeError: cffi library 'suitesparse_graphblas._graphblas' has no
function, constant or global variable named 'GxB_FC32'
Add the complex entries only if supports_complex(), as the rest of the
package does. test_io.py now runs in that build, including the
binwrite/binread round trip of every type in grb_types.
Without complex types neither GrB_FC64 nor GxB_FC64 exists, so
libget("GrB_FC64") raises AttributeError. GrB_HYPER_SWITCH still checks
the fallback to GxB_ in every build.
matrix, vector, scalar, monoid and iterator define their fc32 and fc64 functions under `if supports_complex():`. Check the names in both kinds of build: all of them with complex types, and none without, rather than functions that would fail on a missing lib attribute.
Add one job that builds with SUITESPARSE_GRAPHBLAS_NO_COMPLEX=1 and runs the same tests, coverage and upload as the others. It is ubuntu-latest with Python 3.15: Linux is the quickest runner, a GIL build skips the free-threaded jobs' threaded run, and the code it tests (the other side of each `if supports_complex():`) is Python that depends on neither the OS nor the Python version. The job is an `include:` entry with a new `source` value, because an entry that only added a key would merge into the existing ubuntu-latest 3.15 job. "Build" checks that supports_complex() is false, so the job can't pass by testing the usual build, and the job uploads to Codecov under its own name.
The `# pragma: no branch` on the `if supports_complex():` in api/matrix, vector, scalar, monoid and iterator, and the `# pragma: no cover` on the `else:` in __init__.py, said that every build declares complex types. The no-complex CI job now takes the other branch, so let coverage measure it: in the report Codecov merges from all jobs, both branches of each check are covered. Each job's own report shows one partial branch per check, as it already did for the tests' own checks.
New tests/test_completeness.py fails when a newer GraphBLAS declares something the package does not cover, instead of relying on hand lists that can go stale. Each expected set comes from cffi's lib and ffi, so the tests also adapt to a build without complex types. - Built-in types: the GrB_/GxB_ names matching BOOL, INT, UINT, FP and FC are checked to be exactly the GrB_Type constants, then compared with grb_types. The bool/signed/unsigned/real/complex partition is derived from each type's GrB_EL_TYPE_CODE against GrB_Type_Code. - Binary file tables: _ss_typecodes, _ss_typenames and grb_types must have the same keys, and each name must equal the type's GrB_NAME. - Compression: the GxB_COMPRESSION_* codecs must be exactly the five known ones, so a new codec prompts a decision about its level, and each must appear in test_io's _serialize_options. - Wrapper families: get_*/set_* (matrix, vector, scalar), *_build_*, *_extract_tuples_*, iterator_get_*, monoid_new_* and monoid_terminal_new_* must cover every built-in type (and udt for the monoid ones). - Sparsity: the GxB_HYPERSPARSE/SPARSE/BITMAP/FULL constants must match the _sparsities tables in test_io and test_iterator.
binread skips a text header of exactly GRB_HEADER_LEN (512) bytes, but binwrite wrote a longer header when the comments didn't fit (over about 330 characters), so binread misread the file. Raise ValueError instead, before the file is opened, so nothing is written and the matrix is restored as on any other error. The strict xfail test now checks that the longest comment that fits round-trips, and that one character more is refused and writes no file.
Member
Author
|
Alright, my agents and I did more. We could probably remove |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
New tests raise coverage of psg's Python code from 70.9% to 88.4% locally (
coverage report: statements and branches, test files included). Theapimodules are at or near 100%. A new CI job builds psg without complex types, so both sides of everysupports_complex()check are tested. Writing the tests turned up bugs, and each fix is its own commit with a test that fails without it:*_get_string. These are global, type, descriptor, semiring, binaryop, unaryop, indexunaryop, indexbinaryop and monoid.char[256], and GraphBLAS copies the whole string.GrB_NAME, which has no length limit;*_get_SIZE.monoid_identityandmonoid_terminal. These use a 256-byte buffer, and GraphBLAS copies the full size of the monoid's type into it.binreadand a truncated header. It read past its buffers, and for some lengths it returned an empty 0x0 matrix. It now raisesEOFErrorat every truncation point.binwritereset the matrix's state. It reset the matrix's sparsity control, hyper switch and bitmap switch. It also emptied the matrix when the header couldn't be built, for example with a non-ASCII comment.binwritewrote filesbinreadcan't read. Comments over about 330 characters made the text header longer than the 512 bytesbinreadskips. It now raisesValueErrorbefore opening the file.check_statusraisedKeyErrorfor GraphBLAS codes it has no exception class for:GrB_ALREADY_SET,GxB_OUTPUT_IS_READONLYandGxB_GPU_ERROR.GraphBLASException:AlreadySet,OutputIsReadonlyandGpuError.GraphBLASException.GrB_Infocode needs its own class, and every object type with a*_errorfunction needs an entry incheck_status's table.GrB_Infocode, oncecreate_headers.pyhas regenerated the headers. Add the code's class and mapping in that PR.suitesparse_graphblas.iofailed to import without complex types.binary.pyusedGxB_FC32andGxB_FC64unconditionally. The new no-complex job found it.burble.is_enabledreturns a bool, as documented, its docstring example works, and its methods raiseGraphBLASExceptionrather thanKeyErrorfor an unknown code;global_get_stringnames the GraphBLAS call that failed;_capture_c_output(a test helper) restores stdout when the call raises, closes the file descriptors it opens, and returns "" for no output on Pyodide;kount,kseekand the return codes correctly;test_matrix_binfile_read_writenow really writes full matrices. It compared a type againstGxB_FULL, which is always true.The no-complex job: SuiteSparse:GraphBLAS can't be built without complex types. Its CMake stops with a fatal error, and
GraphBLAS.hhas an#error. So the job builds psg's bindings without them instead.suitesparse_graphblas_no_complex.hwas already generated bycreate_headers.pyand checked by CI. Nothing had used it since the MSVC complex patch.Held as strict xfail, fixed in a follow-up PR:
nthreadsinserialize_*always raisesInvalidValueon GraphBLAS 10, becauseGxB_NTHREADSis no longer a descriptor field.deserialize_*silently ignores the argument. The follow-up sets it with aGxB_Context.Found, not fixed here:
Variadic GraphBLAS calls are broken with conda-forge's cffi on macOS arm64. A double arrives as 0.0 and an int32 setting doesn't change, with or without
vararg. conda-forge's cffi links conda's libffi; PyPI's cffi links the system libffi and works.test_varargis xfail in that environment only (conda env with cffi 2.0.0 and libffi 3.5.2).Two SuiteSparse:GraphBLAS 10.5.3 segfaults on invalid input, also on the 10.6.0 development branch:
GrB_IndexUnaryOp_set_Stringon positional built-ins such asGrB_TRIL(GB_op_string_set.c:28dereferences a NULL xtype);GxB_BinaryOp_new_IndexOpwith an empty theta (GxB_BinaryOp_new_IndexOp_arena.c:96-97).psg adds no workaround for either.
Evidence
Locally (macOS arm64):
SUITESPARSE_GRAPHBLAS_NO_COMPLEX=1: 740 passed, 14 skipped, 3 xfailed. Merged with the normal run (coverage combine), both branches of every complex check are covered.PYTHONMALLOC=debug -X dev.Each bug-fix commit: its test fails on the parent commit (Verified). Examples:
EOFErroreverywhere after.CI at cc4854c: green, 34 checks pass. Codecov merged 22 uploads to 98.79%. At b9c8d23, the no-complex job ran 705 passed and 14 skipped, and the merged report had no partial branch left in the modules that check
supports_complex().Merge Danger
Door: two-way.
Blast Radius: small.
binreadfile raisesEOFErrorwhere it used to raiseAssertionErrororTypeError, or return an empty 0x0 matrix. Other corrupt input raises what it did before.GrB_ALREADY_SET,GxB_OUTPUT_IS_READONLYandGxB_GPU_ERRORraise the newAlreadySet,OutputIsReadonlyandGpuErrorinstead ofKeyError. Codes unknown to the build raiseGraphBLASException.binwriteraisesValueErrorfor comments that don't fit in the 512-byte header, where it used to write an unreadable file.SUITESPARSE_GRAPHBLAS_NO_COMPLEX, for CI only and not documented. Without it, the build is unchanged.descriptor_get_stringwith a field other thanGrB_NAMEraisesInvalidValue, asGrB_Descriptor_get_SIZEdoes.GrB_Descriptor_get_Stringignores the field and returns the name, or "" when none is set. The other getters already raisedInvalidValuefor a non-string field; checked against the parent for types, unary ops, monoids and semirings.