Skip to content

modernize testing code #3743

@orbeckst

Description

@orbeckst

Is your feature request related to a problem?

The testing code uses pytest and relies on numpy.testing. It contains some deprecated testing constructs such as assert_almost_equal(), assert_array_almost_equal() and some sub-optimal tests (such as testing single floats with an array assertion).

Describe the solution you'd like

Update the testing code, following current best practices, such as

  1. use numpy.testing.assert_allclose() instead of assert_almost_equal() or assert_array_almost_equal() for more consistent floating point comparisons
  2. replace array comparisons for floating point scalars (a single floating point number) with pytest.approx() (see Nuclinfo Major Pair and Minor Pair overhaul #3735 (comment))
  3. ...

Please add additional best practices here or in the comments.

Describe alternatives you've considered

We don't have to do anything right now because everything is working.

How to work on this issue

You can open issues for individual points above, you don't have to work on all of them. If you create a new issue, mention this issue number in the issue text so that it gets linked.

Find occurrences of the constructs that you want to change in the code, e.g.,

cd testsuite/
git grep 'assert_almost_equal'

Figure out how to change the code to get an equivalent result by learning about the different arguments that the old and the new function take and how they affect the assertion. Then pick one example and implement your solution. See if it works. Improve your example until it works. Only then start converting more of the test files. Get feedback from other developers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions