Closed tkoskela closed 10 months ago
Can you update the README.md to reflect how we now create new tests, and in particular how we can specify a different precision to the default?
Can you update the README.md to reflect how we now create new tests, and in particular how we can specify a different precision to the default?
Thanks, good point! I've done it, I hope this has made it a bit simpler to add tests as well.
In the future, you can select "request changes" in the review if you would like to request changes :smiley:
Can you add an example for how to set a precision that is not the default (or add it to the README.md)?
To set a custom precision I would maybe just modify the precision matching the key in the test function. Something like:
@pytest.mark.parametrize("key", ['Harris-Foulkes energy',
'Max force',
'Force residual',
'Total polarisation'])
def test_003(self, key, default_precision, testsuite_directory):
path = os.path.join(testsuite_directory, "test_003_bulk_BTO_polarisation")
res = results(path, key)
if key is 'Total polarisation':
precision = custom_precision
else
precision = default precision
np.testing.assert_allclose(res[0], res[1], rtol = precision, verbose = True)
Doing it through the fixtures seems too complicated
Could we also parametrize the precision in the same way as the key?
Not quite the same way, because then pytest would run through all [precision
, key
] combinations, and I don't think that's what we want? I've been struggling with how to make the parametrization do exactly what I want, given we want slightly different treatment for the keys, the test directories, and the precisions. I can talk you through this tomorrow morning
What I propose we can do, is make precision
a function of key
, which we can then call for each key
value. See #207
You already merged this PR, do you want me to open another one?
Closes #200
Each Fortran test now has its own parametrized python test that specifies the values it checks from the output. I would have liked to also make
results
a fixture, but I couldn't figure out how to pass the path into a fixture.