zarr-python icon indicating copy to clipboard operation
zarr-python copied to clipboard

Broken invocation of `create` in `open_array`

Open d-v-b opened this issue 4 months ago • 1 comments

open_array is designed to either read an existing array or create a new one, if the the store_path object has the mode create and no existing array is found. However, creating an array requires specifying a shape as a positional argument to create, but shape is not one of the parameters of open_array, so open_array will always fail if the "create the array" branch is traversed, unless shape was provided in **kwargs, which is a strange API.

I'm not sure how to rescue this function in a way that preserves its intended functionality -- open_array(..., path='foo', shape=(100,)) will return an array with arbitrary shape if one happens to already exist at path foo, which is not good user experience (the user was expecting an array with shape (100,)). This is an API I always disliked about zarr v2; we should consider whether we want to keep it around.

d-v-b avatar Oct 15 '24 19:10 d-v-b