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
Fix simtk JSON storage in SimStore #961
Fix simtk JSON storage in SimStore #961
Conversation
Switch to using is_storage_iterable everywhere
Codecov Report
@@ Coverage Diff @@
## master #961 +/- ##
=======================================
Coverage 80.25% 80.25%
=======================================
Files 136 136
Lines 14449 14449
=======================================
Hits 11596 11596
Misses 2853 2853 Continue to review full report at Codecov.
|
This is ready for review and comment. I will leave it open for at least 24 hours, merging no earlier than Mon 18 Jan 14:00 GMT (15:00 local). |
Looked at the code, and this is definitely a cleaner implementation so +1 for that. Do you mind adding a test-case that would illustrate the failure/fix? (also to prevent regression later on, as you definitely want to keep the ability to save |
Easier to show with code. The fundamental problem is this: >>> from simtk import unit
>>> from collections.abc import Iterable
>>> q = 2.0 * unit.nanometers
>>> isinstance(q, Iterable)
True I would raise this as a bug, but I think Pete's probably already annoyed at me for not replying quickly on his fix for the simtk.unit bug I filed a couple weeks ago. 😆 (Issue here: In any case, this is why the following things were added to SimStore and the OPS implementation of storage:
If it actually is iterable, we still want to treat as not (the same way we do with numpy). Actually, I should probably move the numpy check into a similar setup in the class lookup: Just use
Good point; will do. |
Ah. I understand now how this differs from the replaced |
Good thing that:
It turns out that I had failed to push the commit with the tests for simtk unit storage! The test you asked for is the last one in that file, and the most recent commit. But better to have the tests I wrote a month ago, too! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good to me.
One comment about the last test, as I think it is sidestepping the test due to caching, but feel free to ignore that if that is a misinterpretation of the test
Co-authored-by: Sander Roet <sanderroet@hotmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why codecov doesn't like it, but this looks good to me now :)
It seems to catch up when the Py27 unit tests finish. For some reason, Py27 takes a really long time to install (I guess conda has improved performance?), so Py37 is finishing notebooks as Py27 is starting them. We do have some tests that are a bit flaky on coverage, so I used to see a few lines (maybe 10 or so) vary in coverage. We should allow drops of 0.05% or so; not sure if I've done that or left it extremely strict. |
Indeed, it seems to update when the tests finish. All green now at least :) |
Switch to using
is_storage_iterable
everywhere.This fixes a problem that
simtk.unit.Quantity
objects couldn't be directly tagged (or, probably, otherwised saved as part of simulation objects).