Skip to content

Only check alternate node type if desired isn't present #696

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 2 commits into from
Aug 26, 2021

Conversation

manzt
Copy link
Member

@manzt manzt commented Jan 27, 2021

This PR rearranges the control flow in open_array and open_group when mode is a, r, or r+, so that fewer store methods are called when the correct node already exists. The previous logic always required two calls to store.__containsitem__ if said array/group already existed. Now, open_array checks if the node is a group only if it is not an array (and vis versa for open_group). This may seem like a minor nit, but store.__containsitem__ can wrap arbitrary complexity and if it hides a network call, you can avoid an unnecessary network request.

I noticed this in the zarr.js implementation because we get a lot of HTTP 404s errors for .zgroup in the console when opening a valid remote array. gzuidhof/zarr.js#73

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/tutorial.rst
  • Changes documented in docs/release.rst
  • AppVeyor and Travis CI passes
  • Test coverage is 100% (Coveralls passes)

@codecov
Copy link

codecov bot commented Jan 27, 2021

Codecov Report

Merging #696 (6510e36) into master (acf6828) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #696   +/-   ##
=======================================
  Coverage   99.94%   99.94%           
=======================================
  Files          31       31           
  Lines       10606    10606           
=======================================
  Hits        10600    10600           
  Misses          6        6           
Impacted Files Coverage Δ
zarr/creation.py 100.00% <100.00%> (ø)
zarr/hierarchy.py 100.00% <100.00%> (ø)

Copy link
Member

@joshmoore joshmoore left a comment

Choose a reason for hiding this comment

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

👍

Merging and just going to suppress my inclination to try to refactor this into a single method call ;)

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.

2 participants