Skip to content

fix: allow GCXS data of any dtype again - #1028

Merged
hameerabbasi merged 2 commits into
pydata:mainfrom
Eliot5566:fix/gcxs-validate-any-dtype
Nov 13, 2026
Merged

hameerabbasi merged 2 commits into
pydata:mainfrom
Eliot5566:fix/gcxs-validate-any-dtype

Conversation

@Eliot5566

@Eliot5566 Eliot5566 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this? (check all applicable)

  • 💾 Refactor
  • 🪄 Feature
  • 🐞 Bug Fix
  • 🔧 Optimization
  • 📚 Documentation
  • 🧪 Test
  • 🛠️ Other

Related issues

What this changes

_validate_gcxs_arrays is jitted and took data as an argument, but it only used its ndim and length. Numba can't type float16, object or longdouble arrays, so since #1015 any GCXS with that data failed to build, and so did ufuncs that return float16 from GCXS input (np.sin on int8, uint8 or bool). The function now takes data.shape[0] instead. GCXS.__init__ already raises if data.ndim != 1 before the call, so that check is not lost. The error messages are unchanged.

New tests build a GCXS from float16, object and longdouble data, and run np.sin on int8 GCXS. All of them fail on main and pass with this change.

One side effect: 18 parametrizations of test_reductions_float16 now XPASS again. That test is marked xfail for a float16 precision difference, so since #1015 it had been "failing" by crashing in the constructor instead, which hid this regression. I left the marker alone.

pytest sparse/numba_backend locally: 7021 passed, 97 xfailed, 57 xpassed. ruff check and ruff format pass.

Checklist

  • Code follows style guide
  • Tests added
  • Documented the changes

This change was written with Claude (an AI assistant), which also ran the checks listed above.

Since pydata#1015, GCXS.__init__ passes `data` to the jitted
_validate_gcxs_arrays, and Numba can't type float16, object or
longdouble arrays, so building a GCXS from them failed, as did ufuncs
that return float16 (np.sin on int8 data). The check only needs the
length of `data`, so pass that instead. `data.ndim` is already checked
before the call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the fix label Nov 12, 2026
hameerabbasi
hameerabbasi previously approved these changes Nov 12, 2026
@hameerabbasi
hameerabbasi enabled auto-merge (squash) November 12, 2026 16:19
…s is

Coverage can't see inside the jitted _validate_gcxs_arrays, so the lines
changed there counted as uncovered. Restore the function and pass a
zero-copy boolean array with the shape of `data` instead, which Numba
can type for any data dtype.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hq1ACTsK85bRrY28fUQ7b3
auto-merge was automatically disabled November 12, 2026 23:00

Head branch was pushed to by a user without write access

@Eliot5566

Copy link
Copy Markdown
Contributor Author

Thanks for the review. codecov/patch failed because three of the four changed lines were inside the jitted _validate_gcxs_arrays, which coverage can't trace. I pushed ad989c3: the jitted function is back to what it is on main, and the caller now passes np.broadcast_to(np.False_, self.data.shape) in place of data. It is a zero-copy array with the same shape, and Numba can type it whatever the dtype of data is, so the only changed source line is in __init__ and is covered. Same tests, 7021 passed locally.

The benchmarks and codecov/project checks also fail on #1026, so I left those alone.

@Eliot5566

Copy link
Copy Markdown
Contributor Author

@hameerabbasi — pushed ad989c3 to fix the codecov/patch failure: the only changed source line is now in __init__ and covered, 7021 tests pass locally. Two things need you when you have a moment: the new CI/codspeed runs are sitting at 'action_required' awaiting approval to run, and the push dismissed the earlier review and turned off auto-merge, so it will need a re-review once CI is green. Thanks!

@hameerabbasi
hameerabbasi enabled auto-merge (squash) November 13, 2026 09:01
@Eliot5566

Copy link
Copy Markdown
Contributor Author

The one required check still pending is Read the Docs. Its build for ad989c3 (#35853254) was killed during pip install .[docs] and ended as "terminated due to inactivity", but the GitHub status never left "in progress", so auto-merge keeps waiting on it. Re-running that build from the Read the Docs dashboard should clear it. I can't retrigger it from my side without pushing, and a push would dismiss the approval again.

The two red checks, codecov/project and benchmarks, are not marked required and fail on main as well.

@hameerabbasi
hameerabbasi merged commit 9c43b36 into pydata:main Nov 13, 2026
14 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: GCXS can't hold float16 or object data since 0.19.3 (np.sin on int8 GCXS crashes)

2 participants