Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] support for ragged arrays #2618

Open
jhamman opened this issue Jan 2, 2025 · 3 comments
Open

[v3] support for ragged arrays #2618

jhamman opened this issue Jan 2, 2025 · 3 comments

Comments

@jhamman
Copy link
Member

jhamman commented Jan 2, 2025

Zarr-Python 2 supported ragged arrays. This functionality has not made it into Zarr-Python 3 yet (see also #2617).

An example demonstrating this functionality using Zarr-Python 2:

z = zarr.empty(4, dtype=object, object_codec=numcodecs.VLenArray(int))
z
<zarr.core.Array (4,) object>
z.filters
[VLenArray(dtype='<i8')]
z[0] = np.array([1, 3, 5])
z[1] = np.array([4])
z[2] = np.array([7, 9, 14])
z[:]
array([array([1, 3, 5]), array([4]), array([ 7,  9, 14]),
       array([], dtype=int64)], dtype=object

This issue tracks the development of ragged arrays support in Zarr-Python 3.

@CSSFrancis
Copy link

Just hopping into this dicusssion, but this does limit the ability for Hyperspy to support zarr 3.0.0. Our usecase is for ragged arrays which should be supported, and don't have the same security issues that directly json encoding a python object.

We could just unwrap the ragged arrays and store them alongside an second array with information of how to recreate the ragged array. Is that the best way to handle this or is there a better way to encode varible length objects.

@d-v-b
Copy link
Contributor

d-v-b commented Jan 10, 2025

I think ragged arrays are definitely in-scope for 3.x, we just haven't had time to implement it.

@CSSFrancis
Copy link

@d-v-b Thanks for the response! There is the VLenBytesCodec which seems like it could handle most of the encoding as long as the underlying array is 1 dimensional? The underlying source says that this might be changed in the future and is not explicitly supporting in v3. Is that still correct?

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

No branches or pull requests

3 participants