Skip to content
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

Future of open...() functions #264

Open
alimanfoo opened this issue May 24, 2018 · 1 comment
Open

Future of open...() functions #264

alimanfoo opened this issue May 24, 2018 · 1 comment

Comments

@alimanfoo
Copy link
Member

Currently there are convenience functions open_array(...) and open_group(...), as well as a multi-purpose open(...).

These functions are a bit of a hangover from the earlier days of Zarr when there were only two storage options, either in memory (dict) or on disk (DirectoryStore). The open...() functions were meant to provide convenience for users who wanted to store data on disk, and who may be coming from h5py or bcolz and so were previosly familiar with a file mode semantics for whether data should be read-only, overwritten, etc. E.g., zarr.open_group(...) is analogous to h5py.File(...).

E.g., the following code for creating a new on-disk array:

z = zarr.open_array('/path/to/array.zarr', mode='w', shape=100, dtype='f8')

...is just meant as syntactic sugar for:

store = zarr.DirectoryStore('/path/to/array.zarr')
z = zarr.create(store=store, shape=100, dtype='f8', overwrite=True)

These days, with more storage options, it may be better to recommend using this second, longer form, because it shows the general pattern for how to instantiate a store then create an array, so it's more obvious how to then adapt the code to using a different storage class.

Also the open...() functions can be a little confusing, e.g. #100.

So I think I'm proposing to modify the tutorial so that the open...() functions are not shown any more, and all examples use the slightly longer syntax where a store is explicitly created first.

I'm not proposing to deprecate the open...() functions, at least not at this stage, as they still may be useful to some users.

@jhamman
Copy link
Member

jhamman commented Feb 3, 2024

xref: #1598, cc @aldenks

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

No branches or pull requests

2 participants