Skip to content

Support Numpy structured arrays containing an object #418

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

Closed
ombschervister opened this issue Mar 20, 2019 · 1 comment
Closed

Support Numpy structured arrays containing an object #418

ombschervister opened this issue Mar 20, 2019 · 1 comment

Comments

@ombschervister
Copy link

Hello!
There are problems when working with NumPy Structured arrays containing an object.

Given the NumPy composite type:
records_dtype = [('col1', object), ('col2', np.float64)]

In numpy, data is retrieved by the name of the column, but in zarr this does not work:

arr = np.array([('1', 1.0), ('22', 2.0), ('333', 3.0)], dtype=records_dtype)
print(arr['col1'])
  1. When creating dataset an exception occurs:
    ds = zarr.array(arr)
    zarr.errors.MetadataError: error decoding metadata: Cannot change data-type for object array.

  2. If you pass 'fill_value = None' to zarr.array(), the dataset is created and the values from it can be read:

    ds = zarr.array(arr, fill_value=None)
    print(ds[:])
    

    But data retrieval by column name does not work:
    print(ds['col1'])
    ValueError: cannot create an OBJECT array from memory buffer

@joshmoore
Copy link
Member

Fixed by #813 (v2.9.4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants