Closed jentjr closed 11 months ago
My suggestion for testing storeinput is to add an element, use writemodel to write the model and then read it back in. The resulting model should be the same.
Am I correct that the writemodel
method needs to be added to class Model
, and the method should initialize all the elements, then use inspect
to store the elements in a nested dictionary? Right now it looks like the inputvalues
from storeinput
are for the individual elements and are not being added to the model.
from timml import *
ml = ModelMaq()
uf = Uflow(ml, slope=0.001, angle=150)
ml.inputvalues
{'self': <timml.model.ModelMaq at 0x7f1cc7e457f0>,
'kaq': 1,
'z': [1, 0],
'c': [],
'npor': 0.3,
'topboundary': 'conf',
'hstar': None,
'f2py': False}
I would have expected the Uflow
element to also be listed. I'm not quite sure how it would work, but I can keep trying.
Should methods be added to write and read a model from a file?
You are right, I never copied the write
and writemodel
methods from TTim. Just added those with https://github.com/mbakker7/timml/commit/0b4abebc7efcf9d96dba84d6f5c4f002e3df5bec
Needs further testing, but the following basic example works:
ml = ModelMaq()
rf = Constant(ml, 20, 20, 33)
ml.ml.writemodel('testmodel.py')
After that, the file testmodel.py
can be run to get the same model back.
Okay, thanks. I'll take a look at it.
@jentjr on a related topic, can you remove the timml readthedocs page that you created? We will then add the new readthedocs page for timml similar to the new ttim readthedocs page. But now the name is already taken by the readthedocs page you created.
I removed the timml readthedocs page I created.
Thanks, @jentjr. The new template for readthedocs is now online. We will start populating it with content in the next few months.
This PR is a bit stale by now. If you still have tests that are worthwhile for TimML, then I suggest you start a new PR and I will close this one. Adding more and better tests is definitely something we need.
Working on adding some tests for #33.