Skip to content

Fix incorrect Group.nmembers for consolidated metadata #3287

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 6 commits into from
Jul 23, 2025

Conversation

csparker247
Copy link
Contributor

@csparker247 csparker247 commented Jul 23, 2025

Addresses the issue where Group.nmembers() doesn't honor the max_depth when the group has consolidated metadata. This simply filters flattened_metadata according to the number of / in the sub-elements' paths, which is analogous to checking the depth.

I'm new to this project, so I'm not sure if the implemented test is sufficient.

Closes #3252

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 23, 2025
Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

Looks good thanks. Could you add a release note (https://zarr.readthedocs.io/en/stable/developers/contributing.html#changelog)?

Can you also ensure that we have test coverage for the case where we raise a ValueError?

with pytest.raises(ValueError, match="max_depth"):
    await group.nmembers(max_depth=-1)

Copy link

codecov bot commented Jul 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.67%. Comparing base (b877f89) to head (9df9683).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3287      +/-   ##
==========================================
+ Coverage   59.65%   59.67%   +0.01%     
==========================================
  Files          78       78              
  Lines        8690     8694       +4     
==========================================
+ Hits         5184     5188       +4     
  Misses       3506     3506              
Files with missing lines Coverage Δ
src/zarr/core/group.py 69.48% <100.00%> (+0.14%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions bot removed the needs release notes Automatically applied to PRs which haven't added release notes label Jul 23, 2025
@csparker247
Copy link
Contributor Author

Done. Let me know if there's anything else.

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

Thanks!

@TomAugspurger TomAugspurger merged commit 9dc744d into zarr-developers:main Jul 23, 2025
30 checks passed
@csparker247 csparker247 deleted the 3252-nmembers-fix branch July 23, 2025 19: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.

Group.nmembers returns incorrect value for consolidated metadata
2 participants