OrderN / CONQUEST-release

Full public release of large scale and linear scaling DFT code CONQUEST
http://www.order-n.org/
MIT License
96 stars 25 forks source link

Refactor the testsuite #201

Closed tkoskela closed 10 months ago

tkoskela commented 11 months ago

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.

davidbowler commented 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?

tkoskela commented 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?

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:

davidbowler commented 10 months ago

Can you add an example for how to set a precision that is not the default (or add it to the README.md)?

tkoskela commented 10 months ago

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

davidbowler commented 10 months ago

Could we also parametrize the precision in the same way as the key?

tkoskela commented 10 months ago

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

tkoskela commented 10 months ago

You already merged this PR, do you want me to open another one?