-
-
Notifications
You must be signed in to change notification settings - Fork 421
docs: clarify difference between load and open in docstrings #3984
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
base: main
Are you sure you want to change the base?
Changes from all commits
be46f34
8a0b4db
25998f0
150a80f
b60db19
12dae45
245e74d
025dc2e
370d194
5febe16
e0fa87d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Clarify the difference between `zarr.load` and `zarr.open` in their docstrings. | ||
| `load` eagerly reads data into an in-memory NumPy array, while `open` returns a | ||
| lazy `Array` or `Group` backed by the store, with `See Also` cross-references | ||
| linking the two. | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -294,12 +294,18 @@ async def load( | |||||||||
|
|
||||||||||
| See Also | ||||||||||
| -------- | ||||||||||
| save | ||||||||||
| save, open | ||||||||||
|
|
||||||||||
| Notes | ||||||||||
| ----- | ||||||||||
| If loading data from a group of arrays, data will not be immediately loaded into | ||||||||||
| memory. Rather, arrays will be loaded into memory as they are requested. | ||||||||||
|
|
||||||||||
| Unlike [`open`][zarr.open], which returns a lazy [`Array`][zarr.Array] or | ||||||||||
| [`Group`][zarr.Group] backed by the store, `load` eagerly reads the data and | ||||||||||
| returns it as an in-memory NumPy array (or a dict of NumPy arrays for a group). | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| Use `open` when you want to read or write data incrementally without loading it | ||||||||||
| all into memory. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| obj = await open(store=store, path=path, zarr_format=zarr_format) | ||||||||||
|
|
@@ -347,6 +353,16 @@ async def open( | |||||||||
| ------- | ||||||||||
| z : array or group | ||||||||||
| Return type depends on what exists in the given store. | ||||||||||
|
|
||||||||||
| See Also | ||||||||||
| -------- | ||||||||||
| load | ||||||||||
|
|
||||||||||
| Notes | ||||||||||
| ----- | ||||||||||
| `open` returns a lazy [`Array`][zarr.Array] or [`Group`][zarr.Group] backed by | ||||||||||
| the store, so data is read and written incrementally. Use [`load`][zarr.load] | ||||||||||
| instead when you want the data eagerly read into an in-memory NumPy array. | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| """ | ||||||||||
|
|
||||||||||
| if mode is None: | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -161,12 +161,18 @@ def load( | |||||||||
|
|
||||||||||
| See Also | ||||||||||
| -------- | ||||||||||
| save, savez | ||||||||||
| save, savez, open | ||||||||||
|
|
||||||||||
| Notes | ||||||||||
| ----- | ||||||||||
| If loading data from a group of arrays, data will not be immediately loaded into | ||||||||||
| memory. Rather, arrays will be loaded into memory as they are requested. | ||||||||||
|
|
||||||||||
| Unlike [`open`][zarr.open], which returns a lazy [`Array`][zarr.Array] or | ||||||||||
| [`Group`][zarr.Group] backed by the store, `load` eagerly reads the data and | ||||||||||
| returns it as an in-memory NumPy array (or a dict of NumPy arrays for a group). | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| Use `open` when you want to read or write data incrementally without loading it | ||||||||||
| all into memory. | ||||||||||
| """ | ||||||||||
| return sync(async_api.load(store=store, zarr_format=zarr_format, path=path)) | ||||||||||
|
|
||||||||||
|
|
@@ -209,6 +215,16 @@ def open( | |||||||||
| ------- | ||||||||||
| z : array or group | ||||||||||
| Return type depends on what exists in the given store. | ||||||||||
|
|
||||||||||
| See Also | ||||||||||
| -------- | ||||||||||
| load | ||||||||||
|
|
||||||||||
| Notes | ||||||||||
| ----- | ||||||||||
| `open` returns a lazy [`Array`][zarr.Array] or [`Group`][zarr.Group] backed by | ||||||||||
| the store, so data is read and written incrementally. Use [`load`][zarr.load] | ||||||||||
| instead when you want the data eagerly read into an in-memory NumPy array. | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| """ | ||||||||||
| obj = sync( | ||||||||||
| async_api.open( | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.