Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changes/3984.doc.md
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`load` eagerly reads data into an in-memory NumPy array, while `open` returns a
`load` eagerly reads data into an in-memory array, while `open` returns a

lazy `Array` or `Group` backed by the store, with `See Also` cross-references
linking the two.
18 changes: 17 additions & 1 deletion src/zarr/api/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
returns it as an in-memory NumPy array (or a dict of NumPy arrays for a group).
returns it as an in-memory array (or a dict of arrays for a group).
The array type is NumPy by default, but follows the configured
buffer prototype (for example, CuPy for GPU use cases).

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)
Expand Down Expand Up @@ -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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
instead when you want the data eagerly read into an in-memory NumPy array.
instead when you want the data eagerly read into an in-memory array
(a NumPy array by default).

"""

if mode is None:
Expand Down
18 changes: 17 additions & 1 deletion src/zarr/api/synchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
returns it as an in-memory NumPy array (or a dict of NumPy arrays for a group).
returns it as an in-memory array (or a dict of arrays for a group).
The array type is NumPy by default, but follows the configured
buffer prototype (for example, CuPy for GPU use cases).

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))

Expand Down Expand Up @@ -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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
instead when you want the data eagerly read into an in-memory NumPy array.
instead when you want the data eagerly read into an in-memory array (a
NumPy array by default).

"""
obj = sync(
async_api.open(
Expand Down
Loading