fortran-lang / minpack

Modernized Minpack: for solving nonlinear equations and nonlinear least squares problems
https://fortran-lang.github.io/minpack/
Other
90 stars 18 forks source link

Testing multiple interfaces #72

Open ivan-pi opened 2 years ago

ivan-pi commented 2 years ago

Currently, MINPACK exports 3 API's:

There are some minimal tests for each of the API's and a big ~messy~ collection of Fortran test functions.

Clearly, some minimal tests for each of the different interfaces are needed in order to test the correctness of the binding, with respect to argument passing, types, side-effects, etc. For the actual algorithms in Fortran however, it doesn't matter in which languages / interface the tests are written.

Does it make sense to write the algorithm tests (#10, #35) in Python?

This would test all three interfaces simultaneously. It also has the advantage of faster development due to dynamic typing, simpler output formatting, and other high-level properties of Python. Moreover the larger Python community could support us with their CI/CD knowledge, e.g. from SciPy and other big Python libraries.

cc @awvwgk @ilayn @certik

awvwgk commented 2 years ago

The issue is the likelihood of the tests flagging problematic behavior, I would only run the Python tests if I work on the Python bindings, while I would always run the Fortran and C tests when working on the actual library. In the CI we will run all tests, but for local development running the Python tests can feel unpractical. Note that the fpm based tests are currently not even running the tests for the C binding because the required fpm feature is not yet released.

certik commented 2 years ago

I personally would test Fortran in Fortran and only focus on Fortran. I don't have good development experience needing more than one language for the day to day tasks.

The Python bindings are fully separate, and yes, they need some tests, but only of those bindings. They can assume that the underlying Fortran code works correctly (if there is a bug, we fix it and add a Fortran test).

ilayn commented 2 years ago

If there is a workflow defined somewhere to setup the environment and invoke the tests, we can still help setting up the infra for that though the errors would probably make sense to you more than us.

awvwgk commented 2 years ago

If there is a workflow defined somewhere to setup the environment and invoke the tests, we can still help setting up the infra for that though the errors would probably make sense to you more than us.

See https://github.com/fortran-lang/minpack#installation for the Fortran and C based tests, if you are also interested in testing the Python bindings follow the instructions at https://github.com/fortran-lang/minpack/tree/main/python#using-pip. Let use know if something is not working as expected.

Generally, the following workflow should be sufficient

# Setup environment
mamba env create -n minpack -f config/ci/python-env.yaml
mamba activate minpack
# Install library
meson setup _build --prefix=$CONDA_PREFIX --libdir=lib
meson install -C _build
# Python bindings
pip install -e python/
pytest --pyargs minpack