Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The narrow fix has appropriate regression coverage and no unresolved review findings.
No open issues 🎉
What changed in this PR
Preserves the recorded shape when loading empty NumPy object arrays without changing nonempty reconstruction.
Changes:
- Allocates empty object arrays using their stored shape.
- Adds 14 regression cases covering bytes/file round trips and empty/nonempty controls.
- Documents the fix in the changelog.
| File | Description |
|---|---|
| skops/io/tests/test_persist.py | Adds shape, dtype, and value round-trip checks. |
| skops/io/_numpy.py | Restores empty arrays using the recorded shape. |
| docs/changes.rst | Documents preserved empty-array dimensions. |
Review effort: Balanced
This branch has not been deployed
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.
Reference Issues/PRs
No linked issue.
What does this implement/fix? Explain your changes.
Preserve the recorded shape when loading an empty NumPy object array. For example:
Reconstructing the nested list loses dimensions after the first zero-length axis. Allocate empty arrays using the already stored shape; keep nonempty reconstruction, the file format and the trust policy unchanged. Add regression coverage for bytes and file round trips, zero-length axes in different positions, and working empty/nonempty controls.
Validation on Windows CPU with Python 3.12.14, NumPy 2.5.4 and scikit-learn 1.9.1:
skops/iosuite, including doctests, audit and old-protocol tests: 1,108 passed, 66 skipped, 1 existing XPASS. The original implementation has the six failures above; the skips and XPASS remain the same. The skips are optional third-party estimators and one empty parameter set.pre-commit run --all-files --show-diff-on-failurehooks pass, including Ruff and pyrefly.Any other comments?
No protocol bump is needed. The full repository suite, optional external estimators, other operating systems and the official Python/dependency matrix were not tested.