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
General cleanup of ObjectStore and Naming #409
Conversation
While you're cleaning up the related stuff, you might fix the docstrings for |
Done. |
# Conflicts: # examples/ipython/alanine.ipynb # examples/ipython/test_pyemma.ipynb
undid a rename of a function that was not necessary and change 4 files. |
This all looks good. Before merging, can you just summarize some of the behaviors in this thread (for documentation purposes)? We've discussed some of it in various threads, but a single place for what finally got merged in would be good. The kinds of things I'd like to have covered in that include:
Those are just a few that come to mind immediately. Anything else you can think of, it would be very useful to document it now, in this PR, so we can find it later for reference. (After doing that, please also mark this PR with the "ref docs" tag.) Once that's done, I'll give it one more glance over, but I'm pretty sure it's good to merge. |
SummaryThere are now several new version of the Currently there are
ImmutabilityChanging immutable objects is highly not recommended if not forbidden by law :) The underlying netcdf of course allows you to change objects, but the storage itself does not provide highlevel functions to do so. The main reason is that objects use references to point to other already stored objects. If you were tl change an object this will affect all referencing objects at once. The big question always is, if this is intented or not. You could in principle allow chaning an object but it would be seen as if that object was always a different one. If you now load an object that references this object its constructor might create a different object which could lead to more changes in other objects, etc. To play devils advocat there is no way to predict what will happen. Or what the loaded objects will look like. Hence: Do no change immutable objects. If you want to do that anyway. You can (in most stores) by using
|
Thanks for adding the docs to this! Merging, and I'm sure we'll refer to this when writing official documentation! |
General cleanup of ObjectStore and Naming
Overview
This PR includes PR #406 and #398 and simplifies the mess in the code. Especially in
object.py
.All relevant changes are in files from netcdfplus. All other are just renames that are related and corrections to docstrings, etc. So for review you need to look at objects.py mostly.
Important changes
has_name
in object store that sets, if.name
should be saved you now useNamedObjectStore
instead ofObjectStore
. This has two important advantages: 1. The code is much cleaner sinceNamedObjectStore
is not subclassed and only contains the code that handles naming. And 2. The code is faster since I removed unnecessary checks for handling names in objects that do not support naming.UniqueNamedObjectStore
that add on top of naming that names must be unique. This is probably useful for CVs etc.DictStore
andImmutableDictStore
. The first implements a dict like structure that can be used for tags, see PR A dictionary like store #406 and the second add that keys can only be set once.VariableStore
. See PR Use a generic object store for simple (enough) objects #398. This is a shortcut to create a store that does not store using JSON but creates tables in the netcdf and handles saving and storing of the object. This is very useful if you have a simple class there you just want to store member variables which are either native variables (bumpy array, str, int, etc) or storable objects. This reduces code redundancy and makes the code much better maintainable and it is MUCH easier for users to create their ownStore
class:class:
directive)test_netcdfplus.ipynb
that checks all the different stores and acts at the same time as a limited guide through all the features.To Do
This should close #398, #406, #372.