Skip to content

Commit e77c701

Browse files
jsignelld-v-b
andauthored
Add human readable size for No. bytes stored to info_complete (#3190)
* Add human readable size for No. bytes stored in info_complete * Fix docs for `info_complete` change * Update changelog --------- Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
1 parent 0acf550 commit e77c701

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

changes/3190.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add human readable size for No. bytes stored to `info_complete`

docs/user-guide/arrays.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ prints additional diagnostics, e.g.::
212212
Serializer : BytesCodec(endian=<Endian.little: 'little'>)
213213
Compressors : (BloscCodec(typesize=4, cname=<BloscCname.zstd: 'zstd'>, clevel=3, shuffle=<BloscShuffle.bitshuffle: 'bitshuffle'>, blocksize=0),)
214214
No. bytes : 400000000 (381.5M)
215-
No. bytes stored : 3558573
215+
No. bytes stored : 3558573 (3.4M)
216216
Storage ratio : 112.4
217217
Chunks Initialized : 100
218218

@@ -286,7 +286,7 @@ Here is an example using a delta filter with the Blosc compressor::
286286
>>> compressors = zarr.codecs.BloscCodec(cname='zstd', clevel=1, shuffle=zarr.codecs.BloscShuffle.shuffle)
287287
>>> data = np.arange(100000000, dtype='int32').reshape(10000, 10000)
288288
>>> z = zarr.create_array(store='data/example-9.zarr', shape=data.shape, dtype=data.dtype, chunks=(1000, 1000), filters=filters, compressors=compressors)
289-
>>> z.info
289+
>>> z.info_complete()
290290
Type : Array
291291
Zarr format : 3
292292
Data type : Int32(endianness='little')
@@ -300,6 +300,9 @@ Here is an example using a delta filter with the Blosc compressor::
300300
Serializer : BytesCodec(endian=<Endian.little: 'little'>)
301301
Compressors : (BloscCodec(typesize=4, cname=<BloscCname.zstd: 'zstd'>, clevel=1, shuffle=<BloscShuffle.shuffle: 'shuffle'>, blocksize=0),)
302302
No. bytes : 400000000 (381.5M)
303+
No. bytes stored : 826
304+
Storage ratio : 484261.5
305+
Chunks Initialized : 0
303306

304307
For more information about available filter codecs, see the `Numcodecs
305308
<https://numcodecs.readthedocs.io/>`_ documentation.
@@ -616,7 +619,7 @@ Sharded arrays can be created by providing the ``shards`` parameter to :func:`za
616619
Serializer : BytesCodec(endian=None)
617620
Compressors : (ZstdCodec(level=0, checksum=False),)
618621
No. bytes : 100000000 (95.4M)
619-
No. bytes stored : 3981473
622+
No. bytes stored : 3981473 (3.8M)
620623
Storage ratio : 25.1
621624
Shards Initialized : 100
622625

docs/user-guide/groups.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ property. E.g.::
139139
Serializer : BytesCodec(endian=<Endian.little: 'little'>)
140140
Compressors : (ZstdCodec(level=0, checksum=False),)
141141
No. bytes : 8000000 (7.6M)
142-
No. bytes stored : 1614
142+
No. bytes stored : 1614 (1.6K)
143143
Storage ratio : 4956.6
144144
Chunks Initialized : 10
145145
>>> baz.info

docs/user-guide/performance.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ ratios, depending on the correlation structure within the data. E.g.::
133133
Serializer : BytesCodec(endian=<Endian.little: 'little'>)
134134
Compressors : (ZstdCodec(level=0, checksum=False),)
135135
No. bytes : 400000000 (381.5M)
136-
No. bytes stored : 342588911
136+
No. bytes stored : 342588911 (326.7M)
137137
Storage ratio : 1.2
138138
Chunks Initialized : 100
139139
>>> with zarr.config.set({'array.order': 'F'}):
@@ -153,7 +153,7 @@ ratios, depending on the correlation structure within the data. E.g.::
153153
Serializer : BytesCodec(endian=<Endian.little: 'little'>)
154154
Compressors : (ZstdCodec(level=0, checksum=False),)
155155
No. bytes : 400000000 (381.5M)
156-
No. bytes stored : 342588911
156+
No. bytes stored : 342588911 (326.7M)
157157
Storage ratio : 1.2
158158
Chunks Initialized : 100
159159

src/zarr/core/_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def __repr__(self) -> str:
133133

134134
if self._count_bytes_stored is not None:
135135
template += "\nNo. bytes stored : {_count_bytes_stored}"
136-
kwargs["_count_stored"] = byte_info(self._count_bytes_stored)
136+
kwargs["_count_bytes_stored"] = byte_info(self._count_bytes_stored)
137137

138138
if (
139139
self._count_bytes is not None

tests/test_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_array_info(zarr_format: ZarrFormat) -> None:
7979

8080

8181
@pytest.mark.parametrize("zarr_format", ZARR_FORMATS)
82-
@pytest.mark.parametrize("bytes_things", [(1_000_000, "976.6K", 500_000, "500000", "2.0", 5)])
82+
@pytest.mark.parametrize("bytes_things", [(1_000_000, "976.6K", 500_000, "488.3K", "2.0", 5)])
8383
def test_array_info_complete(
8484
zarr_format: ZarrFormat, bytes_things: tuple[int, str, int, str, str, int]
8585
) -> None:
@@ -120,7 +120,7 @@ def test_array_info_complete(
120120
Serializer : BytesCodec(endian=<Endian.little: 'little'>)
121121
Compressors : ()
122122
No. bytes : {count_bytes} ({count_bytes_formatted})
123-
No. bytes stored : {count_bytes_stored_formatted}
123+
No. bytes stored : {count_bytes_stored} ({count_bytes_stored_formatted})
124124
Storage ratio : {storage_ratio_formatted}
125125
Chunks Initialized : 5""")
126126

0 commit comments

Comments
 (0)