Skip to content

Write zarr v3 arrays of strings with HDF5IO and wrap zarr v3 arrays with H5DataIO - #1618

Open
h-mayorquin wants to merge 1 commit into
devfrom
zarr_arrrays_support
Open

h-mayorquin wants to merge 1 commit into
devfrom
zarr_arrrays_support

Conversation

@h-mayorquin

Copy link
Copy Markdown
Contributor

Motivation

This PR solves two things that fail when writing zarr v3 arrays to HDF5:

  1. HDF5IO.get_type infers the type of a dataset from its first element, and zarr v3 returns a 0-d array from data[0] where zarr v2 returned a scalar. For strings, bytes and objects that 0-d array has an unsized numpy type (np.str_, np.bytes_, np.object_ or str) that h5py cannot create a dataset from. get_type now uses the Python value the array holds, so these arrays get H5_TEXT or H5_BINARY as with zarr v2. Numeric 0-d arrays keep their numpy type.
  2. H5DataIO rejected zarr v3 arrays because they are not Iterable anymore. Its data now accepts the array_data types, which include zarr.Array, as DataIO already does.

Both are necessary for the zarr version 3 support across the ecosystem, and in particular to move the zarr extra to zarr v3, which I will open next. The test of get_type uses plain numpy 0-d arrays and fails without the fix in any environment. The test of H5DataIO only fails without the fix on zarr v3, so it is a regression test for when the extra moves.

How to test the behavior?

Tests included

Checklist

  • Did you update CHANGELOG.md with your changes?
  • Does the PR clearly describe the problem and the solution?
  • Have you reviewed our Contributing Guide?
  • Does the PR use "Fix #XXX" notation to tell GitHub to close the relevant issue numbered XXX when the PR is merged?

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.17%. Comparing base (cf6f249) to head (f0460ea).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1618   +/-   ##
=======================================
  Coverage   93.17%   93.17%           
=======================================
  Files          41       41           
  Lines       10304    10307    +3     
  Branches     2132     2133    +1     
=======================================
+ Hits         9601     9604    +3     
  Misses        423      423           
  Partials      280      280           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

1 participant