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
Model JSON format #232
Model JSON format #232
Conversation
Additional changes: we have never used the SourceRegistry, so I removed it. I also removed the commented-out "to_string" function on the registries. |
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.
@kaklise the code files we went over should be marked as "viewed". The documentation files should still pop up right away when you view the PR "Files changed". Assuming this works the way I think it should.
Well, shoot. I will go in and reverse that change.
|
Created a wntr/network/io.py that now houses the main code for reading/creating/appending to/writing WaterNetworkModel files. The WaterNetworkModel class now calls the functions in this module instead of containing the code to do these IO operations. |
updated release notes
This PR adds full
to_dict
andfrom_dict
functionality to the WaterNetworkModel. Additionally, this functionality is tested both using just dictionaries but also passing the dictionary in to and out of a JSON formatted file. Any format which can store a dictionary and then produce a dictionary when read in should also work (pickle, yaml, hdf5, etc.).The
to_dict()
andwrite_json(f)
functions are available on a WaterNetworkModel object.The
from_dict(d)
andread_json(f)
function is a class method on the WaterNetworkModel class and are aliased as standalone functions in thewntr.network
module.