Skip to content
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

WIP: Include some tests of store equality #357

Closed
wants to merge 14 commits into from
Closed

WIP: Include some tests of store equality #357

wants to merge 14 commits into from

Conversation

jakirkham
Copy link
Member

Provide a few tests that check to see if different stores compare equal or not.

Note: Currently this fails for a few stores. Hopefully this will be a good point to debug and fix those.

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
  • Docs build locally (e.g., run tox -e docs)
  • AppVeyor and Travis CI passes
  • Test coverage is 100% (Coveralls passes)

@alimanfoo
Copy link
Member

Thanks @jakirkham. FWIW we might need to think a bit about what it should mean for two stores to compare equal. Currently, for example, two DirectoryStore objects will compare equal if they both use the same directory path on the file system. Consequently, two DirectoryStore objects that use different directory paths will always compare unequal, regardless of what data are stored there. Also, a DirectoryStore object and a store object of a different class (e.g., ZipStore) will always compare unequal, regardless of what data are stored. This seemed like a simple and sensible thing to do at the time I wrote those storage classes, but I'll need to go back and try to remember why. Looking now to find what tests cover the current store __eq__() implementations...

@alimanfoo
Copy link
Member

So I'm pretty sure that the __eq__() implementations on the store classes are not currently tested directly, however they will be used inside the Array.__eq__() implementation and in the Group.__eq__() implementation. Now trying to find where those are tested...

@alimanfoo
Copy link
Member

OK, Group equality is used in several tests in the test_hierarchy module, e.g., test_require_group, test_getitem_contains_iterator, and test_paths.

Struggling to find where Array.__eq__() is tested...

@alimanfoo
Copy link
Member

OK, got it. We currently rely on Array.__eq__() in several tests within the test_hierarchy module, e.g., here, here, here. We don't currently test it within the test_core module.

@alimanfoo
Copy link
Member

Reviewing the current tests, I think the current implementations of __eq__() in the Array, Group and store classes do serve the tests well.

Is there a reason for considering a different behaviour for the store __eq__() implementations?

@jakirkham
Copy link
Member Author

Based on our discussions in issue ( #349 ) and the problem seen in issue ( #348 ), it does seem like we need to start testing whether stores compare equal and if this is as expected to catch and remove bugs.

@alimanfoo
Copy link
Member

Based on our discussions in issue ( #349 ) and the problem seen in issue ( #348 ), it does seem like we need to start testing whether stores compare equal and if this is as expected to catch and remove bugs.

FWIW if we switch to using DictStore as the default store, then #348 should go away. I.e., we will get consistent behaviour for array equals comparison across all stores, which is essentially that two arrays will compare equal iff they share the same storage.

@pep8speaks
Copy link

pep8speaks commented Feb 13, 2019

Hello @jakirkham! Thanks for updating the PR.

Line 4:80: E501 line too long (80 > 79 characters)
Line 8:80: E501 line too long (86 > 79 characters)
Line 9:80: E501 line too long (82 > 79 characters)
Line 10:80: E501 line too long (84 > 79 characters)
Line 11:80: E501 line too long (84 > 79 characters)
Line 12:80: E501 line too long (85 > 79 characters)
Line 13:80: E501 line too long (81 > 79 characters)
Line 14:80: E501 line too long (89 > 79 characters)
Line 43:80: E501 line too long (84 > 79 characters)
Line 44:80: E501 line too long (80 > 79 characters)
Line 102:80: E501 line too long (83 > 79 characters)
Line 125:80: E501 line too long (84 > 79 characters)
Line 151:80: E501 line too long (85 > 79 characters)
Line 152:80: E501 line too long (83 > 79 characters)
Line 164:80: E501 line too long (85 > 79 characters)
Line 210:80: E501 line too long (92 > 79 characters)
Line 281:80: E501 line too long (86 > 79 characters)
Line 308:80: E501 line too long (80 > 79 characters)
Line 317:80: E501 line too long (90 > 79 characters)
Line 326:80: E501 line too long (85 > 79 characters)
Line 327:80: E501 line too long (80 > 79 characters)
Line 377:80: E501 line too long (81 > 79 characters)
Line 380:80: E501 line too long (83 > 79 characters)
Line 382:80: E501 line too long (89 > 79 characters)
Line 406:80: E501 line too long (94 > 79 characters)
Line 467:80: E501 line too long (80 > 79 characters)
Line 673:80: E501 line too long (80 > 79 characters)
Line 705:80: E501 line too long (84 > 79 characters)
Line 706:80: E501 line too long (83 > 79 characters)
Line 754:80: E501 line too long (83 > 79 characters)
Line 765:80: E501 line too long (87 > 79 characters)
Line 922:80: E501 line too long (80 > 79 characters)
Line 937:80: E501 line too long (80 > 79 characters)
Line 1014:80: E501 line too long (85 > 79 characters)
Line 1024:80: E501 line too long (82 > 79 characters)
Line 1025:80: E501 line too long (83 > 79 characters)
Line 1072:80: E501 line too long (80 > 79 characters)
Line 1074:80: E501 line too long (83 > 79 characters)
Line 1085:80: E501 line too long (80 > 79 characters)
Line 1097:80: E501 line too long (80 > 79 characters)
Line 1104:80: E501 line too long (88 > 79 characters)
Line 1108:80: E501 line too long (82 > 79 characters)
Line 1117:80: E501 line too long (88 > 79 characters)
Line 1126:80: E501 line too long (84 > 79 characters)
Line 1127:80: E501 line too long (83 > 79 characters)
Line 1141:80: E501 line too long (87 > 79 characters)
Line 1145:80: E501 line too long (80 > 79 characters)
Line 1159:80: E501 line too long (89 > 79 characters)
Line 1333:80: E501 line too long (85 > 79 characters)
Line 1336:80: E501 line too long (88 > 79 characters)
Line 1346:80: E501 line too long (80 > 79 characters)
Line 1359:80: E501 line too long (80 > 79 characters)
Line 1361:80: E501 line too long (80 > 79 characters)
Line 1365:80: E501 line too long (84 > 79 characters)
Line 1376:80: E501 line too long (80 > 79 characters)
Line 1388:80: E501 line too long (80 > 79 characters)
Line 1390:80: E501 line too long (80 > 79 characters)
Line 1394:80: E501 line too long (82 > 79 characters)
Line 1395:80: E501 line too long (83 > 79 characters)
Line 1418:80: E501 line too long (83 > 79 characters)
Line 1457:80: E501 line too long (83 > 79 characters)
Line 1460:80: E501 line too long (87 > 79 characters)
Line 1527:80: E501 line too long (83 > 79 characters)
Line 1536:80: E501 line too long (87 > 79 characters)
Line 1547:80: E501 line too long (80 > 79 characters)
Line 1560:80: E501 line too long (80 > 79 characters)
Line 1562:80: E501 line too long (80 > 79 characters)
Line 1566:80: E501 line too long (84 > 79 characters)
Line 1572:80: E501 line too long (86 > 79 characters)
Line 1573:80: E501 line too long (90 > 79 characters)
Line 1575:80: E501 line too long (87 > 79 characters)
Line 1576:80: E501 line too long (86 > 79 characters)
Line 1583:80: E501 line too long (89 > 79 characters)
Line 1584:80: E501 line too long (87 > 79 characters)
Line 1591:80: E501 line too long (83 > 79 characters)
Line 1592:80: E501 line too long (84 > 79 characters)
Line 1593:80: E501 line too long (89 > 79 characters)
Line 1597:80: E501 line too long (84 > 79 characters)
Line 1598:80: E501 line too long (87 > 79 characters)
Line 1701:80: E501 line too long (81 > 79 characters)
Line 1702:80: E501 line too long (80 > 79 characters)
Line 1711:80: E501 line too long (87 > 79 characters)
Line 1720:80: E501 line too long (90 > 79 characters)
Line 1727:80: E501 line too long (91 > 79 characters)
Line 1731:80: E501 line too long (91 > 79 characters)
Line 1749:80: E501 line too long (82 > 79 characters)
Line 1750:80: E501 line too long (89 > 79 characters)
Line 1755:80: E501 line too long (82 > 79 characters)
Line 1797:80: E501 line too long (83 > 79 characters)
Line 1813:80: E501 line too long (86 > 79 characters)
Line 1868:80: E501 line too long (86 > 79 characters)
Line 1905:80: E501 line too long (80 > 79 characters)
Line 2125:80: E501 line too long (80 > 79 characters)
Line 2222:80: E501 line too long (80 > 79 characters)
Line 2285:80: E501 line too long (80 > 79 characters)
Line 2299:80: E501 line too long (86 > 79 characters)
Line 2332:80: E501 line too long (85 > 79 characters)

Line 24:80: E501 line too long (82 > 79 characters)
Line 25:80: E501 line too long (81 > 79 characters)
Line 180:80: E501 line too long (85 > 79 characters)
Line 750:80: E501 line too long (82 > 79 characters)
Line 912:80: E501 line too long (83 > 79 characters)
Line 939:80: E501 line too long (80 > 79 characters)
Line 1197:80: E501 line too long (81 > 79 characters)
Line 1318:80: E501 line too long (85 > 79 characters)
Line 1319:80: E501 line too long (89 > 79 characters)
Line 1351:80: E501 line too long (84 > 79 characters)
Line 1352:80: E501 line too long (84 > 79 characters)
Line 1353:80: E501 line too long (89 > 79 characters)
Line 1354:80: E501 line too long (89 > 79 characters)

Comment last updated on February 13, 2019 at 08:41 Hours UTC

Provide a few tests that check to see if different stores compare equal
or not.
As the check against `root` will turn into a recursive check throughout
the `DictStore`'s contents, make it the last thing checked. That we if
any of the fast checks invalidate equality, we can shortcut the content
check.
Make sure to compare `DirectoryStore`'s contents if their paths differ
instead of just returning `False`.
Instead of trying to implement a custom `__eq__` for
`NestedDirectoryStore`, fallback to the `DirectoryStore` implementation
once we have verified they are the same type.
Ensure that if the two `ZipStore`s are in two different places, we still
check their contents.
Make sure that if nothing simple automatically fails or passes the
`__eq__` that we fallback to comparing the contents of the two stores.
@jakirkham jakirkham changed the title Include some tests of store equality WIP: Include some tests of store equality Feb 13, 2019
The equality test of store note only requires that stores have the same
content, but that they actually be views onto the same data. Hence this
test was previously incorrect. So we now force this case of two stores
with identical data to be not equal.
As the `==`s comparison here results in recursive check through the
`DictStore`'s contents and we want to test identity with `__eq__`
instead, ensure that the two `root`'s are in fact the same object
as opposed to testing their equality.
Ensure that two stores are only equal if they view the same data.
Make sure that equality means they view the same data.
@jakirkham
Copy link
Member Author

So I've made some changes inline with the intent. There will still be a failure for the dict case that we can discuss.

@jakirkham
Copy link
Member Author

So I'm pretty sure that the __eq__() implementations on the store classes are not currently tested directly, however they will be used inside the Array.__eq__() implementation and in the Group.__eq__() implementation.

I'm not quite following this. Wouldn't we want to ensure that two Arrays have the same content regardless of where they are stored? Would also be curious why wouldn't we want to compare Groups' contents as well. Thoughts?

@alimanfoo
Copy link
Member

alimanfoo commented Feb 19, 2019 via email

@jakirkham jakirkham deleted the branch zarr-developers:master May 23, 2022 20:57
@jakirkham jakirkham closed this May 23, 2022
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