Skip to content

Directly allow zarr arrays as "out" parameter of ufuncs (if possible) #566

Open
@s-m-e

Description

@s-m-e

I just ran into the following "problem":

import numpy as np
import zarr
a = np.arange(0, 16, dtype = 'float32').reshape(4, 4)
b = zarr.open('test.zarr', mode = 'w', shape = (4, 4), chunks = (2, 2), dtype = 'f4')
np.multiply(a, 2, out = b[:, :]) # does not change file(s) on disk
np.multiply(a, 2, out = b) # TypeError: return arrays must be of ArrayType

Some ufuncs (but not those from numpy itself) allow zarr arrays as out-parameters. I.e. the result of the computation is directly written to disk. numpy in fact rejects zarr arrays because they are not of "ArrayType". Could this be changed? I am not entirely sure given the nature of numpy's memory management.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features or improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions