mbakker7 / timml

An analytic element model for steady multi-layer flow
MIT License
38 stars 21 forks source link

Add tests #37

Closed jentjr closed 11 months ago

jentjr commented 5 years ago

Working on adding some tests for #33.

mbakker7 commented 5 years 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.

jentjr commented 5 years ago

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?

mbakker7 commented 5 years ago

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.

jentjr commented 5 years ago

Okay, thanks. I'll take a look at it.

mbakker7 commented 1 year ago

@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.

jentjr commented 1 year ago

I removed the timml readthedocs page I created.

mbakker7 commented 1 year ago

Thanks, @jentjr. The new template for readthedocs is now online. We will start populating it with content in the next few months.

mbakker7 commented 12 months ago

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.