Swapped all numpy assert_allclose & assert_array_equal to pytest approx in tests#780
Open
gohil-jay wants to merge 17 commits intoscikit-hep:developfrom
Open
Swapped all numpy assert_allclose & assert_array_equal to pytest approx in tests#780gohil-jay wants to merge 17 commits intoscikit-hep:developfrom
gohil-jay wants to merge 17 commits intoscikit-hep:developfrom
Conversation
henryiii
reviewed
Aug 16, 2022
| Cat = bh.axis.StrCategory if isinstance(ref[0], str) else bh.axis.IntCategory | ||
| a = Cat(ref, growth=growth) | ||
| assert_array_equal(a, ref) | ||
| assert a == approx(ref) |
Member
There was a problem hiding this comment.
Suggested change
| assert a == approx(ref) | |
| assert np.asarray(a) == approx(ref) |
Quick fix. But is it possible to control how pytest treats approx?
Member
|
Why do you replace the numpy assserts with pytest.approx? The messages produced by numpy.assert_allclose etc are better than those from pytest.approx, and numpy.assert_allclose works on array-like types, too. |
Collaborator
Author
|
I believe this came up while working on the comparison issue but I don't remember the exact details on why! @henryiii do you want to chime in here? |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses 2c81964 commit further.
I realized that there are other asserts that are imported directly which I missed in previous commit, so this covers all of them.