Skip to content

Add human readable size for No. bytes stored to info_complete #3190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 7, 2025

Conversation

jsignell
Copy link
Contributor

@jsignell jsignell commented Jul 1, 2025

Example:

>>> z.info_complete()
Type               : Array
Zarr format        : 3
Data type          : Int32(endianness='little')
Fill value         : 0
Shape              : (10000, 10000)
Chunk shape        : (1000, 1000)
Order              : C
Read-only          : False
Store type         : LocalStore
Filters            : ()
Serializer         : BytesCodec(endian=<Endian.little: 'little'>)
Compressors        : (BloscCodec(typesize=4, cname=<BloscCname.zstd: 'zstd'>, clevel=3, shuffle=<BloscShuffle.bitshuffle: 'bitshuffle'>, blocksize=0),)
No. bytes          : 400000000 (381.5M)
No. bytes stored   : 3558573 (3.4M)
Storage ratio      : 112.4
Chunks Initialized : 100

Note: I think this was the intention, looks like just a dict key misalignment.

TODO:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/user-guide/*.rst
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

@github-actions github-actions bot added the needs release notes Automatically applied to PRs which haven't added release notes label Jul 1, 2025
@@ -133,7 +133,7 @@ def __repr__(self) -> str:

if self._count_bytes_stored is not None:
template += "\nNo. bytes stored : {_count_bytes_stored}"
kwargs["_count_stored"] = byte_info(self._count_bytes_stored)
kwargs["_count_bytes_stored"] = byte_info(self._count_bytes_stored)
Copy link
Contributor

Choose a reason for hiding this comment

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

we got bitten by kwargs here :(

Copy link
Contributor

Choose a reason for hiding this comment

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

for posterity, if we really want to use kwargs (and I think we should not), we should define some typeddicts to model what goes in kwargs. something for a later pr.

@@ -285,7 +285,7 @@ Here is an example using a delta filter with the Blosc compressor::
>>> compressors = zarr.codecs.BloscCodec(cname='zstd', clevel=1, shuffle=zarr.codecs.BloscShuffle.shuffle)
>>> data = np.arange(100000000, dtype='int32').reshape(10000, 10000)
>>> z = zarr.create_array(store='data/example-9.zarr', shape=data.shape, dtype=data.dtype, chunks=(1000, 1000), filters=filters, compressors=compressors)
>>> z.info
>>> z.info_complete()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the only real change to docs. Seems like if you are explaining about compression it's useful to show this extra information.

@@ -79,7 +79,7 @@ def test_array_info(zarr_format: ZarrFormat) -> None:


@pytest.mark.parametrize("zarr_format", ZARR_FORMATS)
@pytest.mark.parametrize("bytes_things", [(1_000_000, "976.6K", 500_000, "500000", "2.0", 5)])
@pytest.mark.parametrize("bytes_things", [(1_000_000, "976.6K", 500_000, "488.3K", "2.0", 5)])
Copy link
Contributor

Choose a reason for hiding this comment

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

i love "bytes_things"

Copy link
Contributor

@d-v-b d-v-b left a comment

Choose a reason for hiding this comment

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

thanks! this is a nice improvement

@d-v-b d-v-b added this to the 3.0.10 milestone Jul 3, 2025
@dstansby dstansby removed this from the 3.0.10 milestone Jul 6, 2025
@dstansby
Copy link
Contributor

dstansby commented Jul 6, 2025

Thanks a lot, this is a nice improvement! Could you add a file to the /changes directory with a changelog entry? Otherwise I think this is good to go.

@github-actions github-actions bot removed the needs release notes Automatically applied to PRs which haven't added release notes label Jul 7, 2025
@dstansby dstansby enabled auto-merge (squash) July 7, 2025 15:28
Copy link

codecov bot commented Jul 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.73%. Comparing base (0acf550) to head (8be47e3).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3190   +/-   ##
=======================================
  Coverage   94.73%   94.73%           
=======================================
  Files          78       78           
  Lines        8646     8646           
=======================================
  Hits         8191     8191           
  Misses        455      455           
Files with missing lines Coverage Δ
src/zarr/core/_info.py 94.87% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dstansby dstansby merged commit e77c701 into zarr-developers:main Jul 7, 2025
30 checks passed
@d-v-b
Copy link
Contributor

d-v-b commented Jul 7, 2025

thanks @jsignell!

@jsignell jsignell deleted the info_complete branch July 7, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants