Skip to content

Support for masked arrays (numpy.ma.masked) #3744

Description

@radoering

When I try to store a masked array, I get only an incomprehensible error message:

ValueError: cannot reshape array of size 3 into shape (24,)

See "example 1" for details.

When I use zarr 2 (or zarr 3 with zarr_format=2), there is no error but the mask is just lost. See "example 2".

Example 1

import numpy
import zarr

masked_array = numpy.ma.masked_array([1, 2, 3], mask=[0, 1, 0])
zarr_array = zarr.array(masked_array)

Error Message:

ValueError: cannot reshape array of size 3 into shape (24,)

Example 2

import numpy
import zarr

masked_array = numpy.ma.masked_array([1, 2, 3], mask=[0, 1, 0])
print(masked_array)

zarr_array = zarr.array(masked_array, zarr_format=2)
print(zarr_array[:])

Output:

[1 -- 3]
[1 2 3]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions