timml icon indicating copy to clipboard operation
timml copied to clipboard

Add tests

Open jentjr opened this issue 5 years ago • 4 comments

Working on adding some tests for #33.

jentjr avatar Nov 23 '19 22:11 jentjr

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.

mbakker7 avatar Nov 24 '19 11:11 mbakker7

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?

jentjr avatar Nov 24 '19 14:11 jentjr

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.

mbakker7 avatar Nov 24 '19 17:11 mbakker7

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

jentjr avatar Nov 24 '19 18:11 jentjr

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

mbakker7 avatar Oct 24 '23 13:10 mbakker7

I removed the timml readthedocs page I created.

jentjr avatar Oct 24 '23 23:10 jentjr

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

mbakker7 avatar Oct 25 '23 08:10 mbakker7

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.

mbakker7 avatar Dec 06 '23 15:12 mbakker7