Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.3.4: approx broken when mixing numpy booleans and booleans #13047

Open
t-b opened this issue Dec 9, 2024 · 3 comments
Open

8.3.4: approx broken when mixing numpy booleans and booleans #13047

t-b opened this issue Dec 9, 2024 · 3 comments
Labels
type: bug problem that needs to be addressed type: regression indicates a problem that was introduced in a release which was working previously

Comments

@t-b
Copy link

t-b commented Dec 9, 2024

After updating to pytest 8.3.4 the following code

Python 3.11.10 (main, Nov 20 2024, 15:38:42) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytest
>>> import numpy as np
>>> np.False_ == pytest.approx(False)

returns False where as it returns True with pytest 8.3.3. I would not expect to have to update my code when updating to a patch version.

I would think, without having any clue, that #9354, is the culprit.

$pip list
Package    Version
---------- -------
iniconfig  2.0.0
numpy      2.2.0
packaging  24.2
pip        24.0
pluggy     1.5.0
pytest     8.3.4
setuptools 65.5.0

OS: debian bookworm

@RonnyPfannschmidt
Copy link
Member

Indeed

@RonnyPfannschmidt RonnyPfannschmidt added type: bug problem that needs to be addressed type: regression indicates a problem that was introduced in a release which was working previously labels Dec 9, 2024
@nicoddemus
Copy link
Member

nicoddemus commented Dec 10, 2024

I would not expect to have to update my code when updating to a patch version.

Indeed, unfortunately even though we try our best, sometimes a bug fix might unexpectedly break a valid/existing case.

This is strange however, seems like the post example should work given that we have explicit tests for bool:

    def test_expecting_bool(self) -> None:
        assert True == approx(True)  # noqa: E712
        assert False == approx(False)  # noqa: E712
        assert True != approx(False)  # noqa: E712
        assert True != approx(False, abs=2)  # noqa: E712
        assert 1 != approx(True)

I guess throwing numpy.bool in the mix is causing unexpected problems.

@t-b
Copy link
Author

t-b commented Dec 15, 2024

Thanks both. Sorry for my wording. The rabbit hole got a bit too deep when debugging the problem and finding a pytest bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed type: regression indicates a problem that was introduced in a release which was working previously
Projects
None yet
Development

No branches or pull requests

3 participants