@@ -977,9 +977,17 @@ def _iter_chunk_regions(
977
977
@property
978
978
def nbytes (self ) -> int :
979
979
"""
980
- The number of bytes that can be stored in this array.
980
+ The total number of bytes that can be stored in the chunks of this array.
981
+
982
+ Notes
983
+ -----
984
+ This value is calculated by multiplying the number of elements in the array and the size
985
+ of each element, the latter of which is determined by the dtype of the array.
986
+ For this reason, ``nbytes`` will likely be inaccurate for arrays with variable-length
987
+ dtypes. It is not possible to determine the size of an array with variable-length elements
988
+ from the shape and dtype alone.
981
989
"""
982
- return self .nchunks * self .dtype .itemsize
990
+ return self .size * self .dtype .itemsize
983
991
984
992
async def _get_selection (
985
993
self ,
@@ -1429,7 +1437,7 @@ def _info(
1429
1437
_order = self .order ,
1430
1438
_read_only = self .read_only ,
1431
1439
_store_type = type (self .store_path .store ).__name__ ,
1432
- _count_bytes = self .dtype . itemsize * self . size ,
1440
+ _count_bytes = self .nbytes ,
1433
1441
_count_bytes_stored = count_bytes_stored ,
1434
1442
_count_chunks_initialized = count_chunks_initialized ,
1435
1443
** kwargs ,
@@ -1740,7 +1748,15 @@ def _iter_chunk_coords(
1740
1748
@property
1741
1749
def nbytes (self ) -> int :
1742
1750
"""
1743
<
10000
/td>
- The number of bytes that can be stored in this array.
1751
+ The total number of bytes that can be stored in the chunks of this array.
1752
+
1753
+ Notes
1754
+ -----
1755
+ This value is calculated by multiplying the number of elements in the array and the size
1756
+ of each element, the latter of which is determined by the dtype of the array.
1757
+ For this reason, ``nbytes`` will likely be inaccurate for arrays with variable-length
1758
+ dtypes. It is not possible to determine the size of an array with variable-length elements
1759
+ from the shape and dtype alone.
1744
1760
"""
1745
1761
return self ._async_array .nbytes
1746
1762
0 commit comments