Skip to content

Support Numpy structured arrays containing an object #418

Closed
@ombschervister

Description

@ombschervister

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions