Skip to content

False positives caused by strict equality comparison on NumPy 1.22? #365

Closed as not planned
@crusaderky

Description

@crusaderky

I ran the tests on 100k examples (>8h runtime) on array_api_compat.numpy on NumPy 1.22 (xfails from data-apis/array-api-compat#304), and got several failures.
I didn't investigate thoroughly yet but I suspect that at least some of them may be related to using strict equality comparison instead of almost_eq with a very low relative tolerance.
The equality test is done by _pytest_helpers.py by calling numpy.ndarray.__eq__, which I suspect had issues in old versions of NumPy?

FAILED array_api_tests/test_creation_functions.py::test_linspace - AssertionError: out[0]=0.0, but should be -0.0 [linspace()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_clip - AssertionError: out[()]=-inf but should be -3.4028235677973366e+38 [clip()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_equal[equal(x1, x2)] - AssertionError: out[0]=True, but should be (x1 == x2[0])=False [equal()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_equal[__eq__(x1, x2)] - exceptiongroup.ExceptionGroup: Hypothesis found 2 distinct failures. (2 sub-exceptions)
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_greater[greater(x1, x2)] - AssertionError: out[0]=False, but should be (x1 > x2[0])=True [greater()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_greater[__gt__(x1, x2)] - exceptiongroup.ExceptionGroup: Hypothesis found 2 distinct failures. (2 sub-exceptions)
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_greater_equal[greater_equal(x1, x2)] - AssertionError: out[0]=True, but should be (x1 >= x2[0])=False [greater_equal()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_greater_equal[__ge__(x1, x2)] - AssertionError: out[0]=True, but should be (x1 >= x2[0])=False [__ge__()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_less[less(x1, x2)] - exceptiongroup.ExceptionGroup: Hypothesis found 2 distinct failures. (2 sub-exceptions)
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_less[__lt__(x1, x2)] - AssertionError: out[0]=False, but should be (x1 < x2[0])=True [__lt__()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_less_equal[less_equal(x1, x2)] - AssertionError: out[0]=True, but should be (x1 <= x2[0])=False [less_equal()]
FAILED array_api_tests/test_operators_and_elementwise_functions.py::test_less_equal[__le__(x1, x2)] - exceptiongroup.ExceptionGroup: Hypothesis found 2 distinct failures. (2 sub-exceptions)
FAILED array_api_tests/test_searching_functions.py::test_where - AssertionError: out[(0, 0, 0, 0)]=16777216j, but should be _x2[(0, 0, 0, 0)]=16777217j [where()]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions