Skip to content

Conversation

@mscheltienne
Copy link
Contributor

Fixes deprecation observed in numpy 2.5+ (pre-release):

 .venv/lib/python3.13/site-packages/zarr/codecs/vlen_utf8.py:98: in _decode_single
    decoded.shape = chunk_spec.shape
    ^^^^^^^^^^^^^
E   DeprecationWarning: Setting the shape on a NumPy array has been deprecated in NumPy 2.5.
E   As an alternative, you can create a new view using np.reshape (with copy=False if needed).

@github-actions github-actions bot added the needs release notes Automatically applied to PRs which haven't added release notes label Jan 12, 2026
@github-actions github-actions bot removed the needs release notes Automatically applied to PRs which haven't added release notes label Jan 12, 2026
@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 60.90%. Comparing base (acdd892) to head (2bc0cbc).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/zarr/codecs/vlen_utf8.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3648   +/-   ##
=======================================
  Coverage   60.90%   60.90%           
=======================================
  Files          86       86           
  Lines       10174    10174           
=======================================
  Hits         6196     6196           
  Misses       3978     3978           
Files with missing lines Coverage Δ
src/zarr/codecs/vlen_utf8.py 28.07% <50.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@d-v-b d-v-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@d-v-b d-v-b merged commit e67935a into zarr-developers:main Jan 12, 2026
31 checks passed
@mscheltienne mscheltienne deleted the fix-deprecation-numpy-2.5 branch January 12, 2026 11:31
@mscheltienne
Copy link
Contributor Author

@d-v-b Note that this change is not fully backward compatible, if we want it backward compatible we would set copy=False instead of the default copy=None. I consider that copy=None is an enhancement as it will now:

  • (1) Try to reshape without copy (view)
  • (2) If it can't, reshape with a copy

If we set copy=False, it will explicitly raise if the view is not possible. Up-to-you, let me know if you think this added fallback mechanism is an enhancement or if hiding this copy is detrimental.

@d-v-b
Copy link
Contributor

d-v-b commented Jan 12, 2026

As decoded is an object array, when would we not be able to create a view?

@mscheltienne
Copy link
Contributor Author

Well it should- and personally I don't see the harm in adding this fallback- but if you prefer to have an explicit raise instead to catch eventual future changes that would somehow yield a non contiguous array of objects, then setting copy=False would be better.

@d-v-b
Copy link
Contributor

d-v-b commented Jan 12, 2026

in that case the copy=False option seems good. Probably better to err on the side of avoiding hidden allocations wherever possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants