diff --git a/changes/3081.feature.rst b/changes/3081.feature.rst new file mode 100644 index 0000000000..8cf83ea7c2 --- /dev/null +++ b/changes/3081.feature.rst @@ -0,0 +1 @@ +Adds ``fill_value`` to the list of attributes displayed in the output of the ``AsyncArray.info()`` method. \ No newline at end of file diff --git a/docs/user-guide/arrays.rst b/docs/user-guide/arrays.rst index e6d1bcdc54..5bd6b1500f 100644 --- a/docs/user-guide/arrays.rst +++ b/docs/user-guide/arrays.rst @@ -183,6 +183,7 @@ which can be used to print useful diagnostics, e.g.:: Type : Array Zarr format : 3 Data type : DataType.int32 + Fill value : 0 Shape : (10000, 10000) Chunk shape : (1000, 1000) Order : C @@ -200,6 +201,7 @@ prints additional diagnostics, e.g.:: Type : Array Zarr format : 3 Data type : DataType.int32 + Fill value : 0 Shape : (10000, 10000) Chunk shape : (1000, 1000) Order : C @@ -287,6 +289,7 @@ Here is an example using a delta filter with the Blosc compressor:: Type : Array Zarr format : 3 Data type : DataType.int32 + Fill value : 0 Shape : (10000, 10000) Chunk shape : (1000, 1000) Order : C @@ -601,6 +604,7 @@ Sharded arrays can be created by providing the ``shards`` parameter to :func:`za Type : Array Zarr format : 3 Data type : DataType.uint8 + Fill value : 0 Shape : (10000, 10000) Shard shape : (1000, 1000) Chunk shape : (100, 100) diff --git a/docs/user-guide/groups.rst b/docs/user-guide/groups.rst index d5a0a7ccee..99234bad4e 100644 --- a/docs/user-guide/groups.rst +++ b/docs/user-guide/groups.rst @@ -129,6 +129,7 @@ property. E.g.:: Type : Array Zarr format : 3 Data type : DataType.int64 + Fill value : 0 Shape : (1000000,) Chunk shape : (100000,) Order : C @@ -145,6 +146,7 @@ property. E.g.:: Type : Array Zarr format : 3 Data type : DataType.float32 + Fill value : 0.0 Shape : (1000, 1000) Chunk shape : (100, 100) Order : C diff --git a/docs/user-guide/performance.rst b/docs/user-guide/performance.rst index 42d830780f..88329f11b8 100644 --- a/docs/user-guide/performance.rst +++ b/docs/user-guide/performance.rst @@ -92,6 +92,7 @@ To use sharding, you need to specify the ``shards`` parameter when creating the Type : Array Zarr format : 3 Data type : DataType.uint8 + Fill value : 0 Shape : (10000, 10000, 1000) Shard shape : (1000, 1000, 1000) Chunk shape : (100, 100, 100) @@ -122,6 +123,7 @@ ratios, depending on the correlation structure within the data. E.g.:: Type : Array Zarr format : 3 Data type : DataType.int32 + Fill value : 0 Shape : (10000, 10000) Chunk shape : (1000, 1000) Order : C @@ -141,6 +143,7 @@ ratios, depending on the correlation structure within the data. E.g.:: Type : Array Zarr format : 3 Data type : DataType.int32 + Fill value : 0 Shape : (10000, 10000) Chunk shape : (1000, 1000) Order : F diff --git a/src/zarr/core/_info.py b/src/zarr/core/_info.py index 845552c8be..ee953d4591 100644 --- a/src/zarr/core/_info.py +++ b/src/zarr/core/_info.py @@ -67,7 +67,7 @@ def byte_info(size: int) -> str: return f"{size} ({human_readable_size(size)})" -@dataclasses.dataclass(kw_only=True) +@dataclasses.dataclass(kw_only=True, frozen=True, slots=True) class ArrayInfo: """ Visual summary for an Array. @@ -79,6 +79,7 @@ class ArrayInfo: _type: Literal["Array"] = "Array" _zarr_format: ZarrFormat _data_type: np.dtype[Any] | DataType + _fill_value: object _shape: tuple[int, ...] _shard_shape: tuple[int, ...] | None = None _chunk_shape: tuple[int, ...] | None = None @@ -97,6 +98,7 @@ def __repr__(self) -> str: Type : {_type} Zarr format : {_zarr_format} Data type : {_data_type} + Fill value : {_fill_value} Shape : {_shape}""") if self._shard_shape is not None: diff --git a/src/zarr/core/array.py b/src/zarr/core/array.py index 78b5e92ed6..00ac7c2138 100644 --- a/src/zarr/core/array.py +++ b/src/zarr/core/array.py @@ -1702,6 +1702,7 @@ def _info( return ArrayInfo( _zarr_format=self.metadata.zarr_format, _data_type=_data_type, + _fill_value=self.metadata.fill_value, _shape=self.shape, _order=self.order, _shard_shape=self.shards, diff --git a/tests/test_array.py b/tests/test_array.py index 32f7887007..a6bcd17c4b 100644 --- a/tests/test_array.py +++ b/tests/test_array.py @@ -522,6 +522,7 @@ def test_info_v2(self, chunks: tuple[int, int], shards: tuple[int, int] | None) expected = ArrayInfo( _zarr_format=2, _data_type=np.dtype("float64"), + _fill_value=arr.fill_value, _shape=(8, 8), _chunk_shape=chunks, _shard_shape=None, @@ -539,6 +540,7 @@ def test_info_v3(self, chunks: tuple[int, int], shards: tuple[int, int] | None) expected = ArrayInfo( _zarr_format=3, _data_type=DataType.parse("float64"), + _fill_value=arr.fill_value, _shape=(8, 8), _chunk_shape=chunks, _shard_shape=shards, @@ -564,6 +566,7 @@ def test_info_complete(self, chunks: tuple[int, int], shards: tuple[int, int] | expected = ArrayInfo( _zarr_format=3, _data_type=DataType.parse("float64"), + _fill_value=arr.fill_value, _shape=(8, 8), _chunk_shape=chunks, _shard_shape=shards, @@ -599,6 +602,7 @@ async def test_info_v2_async( expected = ArrayInfo( _zarr_format=2, _data_type=np.dtype("float64"), + _fill_value=arr.metadata.fill_value, _shape=(8, 8), _chunk_shape=(2, 2), _shard_shape=None, @@ -624,6 +628,7 @@ async def test_info_v3_async( expected = ArrayInfo( _zarr_format=3, _data_type=DataType.parse("float64"), + _fill_value=arr.metadata.fill_value, _shape=(8, 8), _chunk_shape=chunks, _shard_shape=shards, @@ -651,6 +656,7 @@ async def test_info_complete_async( expected = ArrayInfo( _zarr_format=3, _data_type=DataType.parse("float64"), + _fill_value=arr.metadata.fill_value, _shape=(8, 8), _chunk_shape=chunks, _shard_shape=shards, diff --git a/tests/test_info.py b/tests/test_info.py index db0fd0ef76..04e6339092 100644 --- a/tests/test_info.py +++ b/tests/test_info.py @@ -54,6 +54,7 @@ def test_array_info(zarr_format: ZarrFormat) -> None: info = ArrayInfo( _zarr_format=zarr_format, _data_type=np.dtype("int32"), + _fill_value=0, _shape=(100, 100), _chunk_shape=(10, 100), _order="C", @@ -66,6 +67,7 @@ def test_array_info(zarr_format: ZarrFormat) -> None: Type : Array Zarr format : {zarr_format} Data type : int32 + Fill value : 0 Shape : (100, 100) Chunk shape : (10, 100) Order : C @@ -92,6 +94,7 @@ def test_array_info_complete( info = ArrayInfo( _zarr_format=zarr_format, _data_type=np.dtype("int32"), + _fill_value=0, _shape=(100, 100), _chunk_shape=(10, 100), _order="C", @@ -107,6 +110,7 @@ def test_array_info_complete( Type : Array Zarr format : {zarr_format} Data type : int32 + Fill value : 0 Shape : (100, 100) Chunk shape : (10, 100) Order : C