Skip to content

Commit

Permalink
stronger docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
d-v-b committed Dec 19, 2024
1 parent 378cbaf commit 254e276
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/zarr/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,9 +977,16 @@ def _iter_chunk_regions(
@property
def nbytes(self) -> int:
"""
The number of bytes that can be stored in the chunks of this array.
The total number of bytes that can be stored in the chunks of this array.
Notes
-----
This value is calculated by multiplying the number of elements in the array and the size
of each element, the latter of which is determined by the dtype of the array.
For this reason, ``nbytes`` will likely be inaccurate for arrays with variable-length
dtypes. It is not possible to determine the size of an array with variable-length elements
from the shape and dtype alone.
"""
# TODO: how can this be meaningful for variable-length types?
return self.size * self.dtype.itemsize

async def _get_selection(
Expand Down Expand Up @@ -1741,7 +1748,15 @@ def _iter_chunk_coords(
@property
def nbytes(self) -> int:
"""
The number of bytes that can be stored in this array.
The total number of bytes that can be stored in the chunks of this array.
Notes
-----
This value is calculated by multiplying the number of elements in the array and the size
of each element, the latter of which is determined by the dtype of the array.
For this reason, ``nbytes`` will likely be inaccurate for arrays with variable-length
dtypes. It is not possible to determine the size of an array with variable-length elements
from the shape and dtype alone.
"""
return self._async_array.nbytes

Expand Down

0 comments on commit 254e276

Please sign in to comment.