forked from sherpa/sherpa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TEST: handle pytest 8.3.4 change in bool tests with approx
Fix sherpa#2202 In pytest 8.3.3 and earlier >>> import numpy as np; import pytest >>> pytest.__version__ '8.3.3' >>> np.ones(2, dtype=bool) == pytest.approx([True, True]) True However, pytest 8.3.4 now causes this to fail >>> import numpy as np; import pytest >>> pytest.__version__ '8.3.4' >>> np.ones(2, dtype=bool) == pytest.approx([True, True]) False This is because of "pytest.approx considers boolean numeric types" pytest-dev/pytest#9353 The solution is to make the "expected" value be a ndarray, and so >>> np.ones(2, dtype=bool) == pytest.approx(np.asarray([True, True])) True holds with both pytest 8.3.3 and 8.3.4. So this commit basically goes through and updates the tests so that we use a ndarray for boolean arrays. An alternative would be to change from assert got == pytest.approx(expected) to something like assert np.all(got == expected) However, the error message when the array lengths are different or an element is different are a **lot less** useful, and the change would be even-more invasive than this change.
- Loading branch information
Showing
13 changed files
with
146 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.