data-apis / array-api-tests

Test suite for the PyData Array APIs standard
https://data-apis.org/array-api-tests/
MIT License
64 stars 41 forks source link

test_linspace error with numpy #195

Open asmeurer opened 1 year ago

asmeurer commented 1 year ago
FAILED array_api_tests/test_creation_functions.py::test_linspace - AssertionError: out[0]=0.0, should be -0.0 [linspace()]
Falsifying example: test_linspace(
    num=1,
    dtype=numpy.float32,
    endpoint=False,
    data=data(...),
)
Draw 1 (start): -0.0
Draw 2 (stop): -1.0
Draw 3 (kw): {'dtype': numpy.float32, 'endpoint': False}

Not clear if this is actually required by the spec or not. See https://data-apis.org/array-api/latest/API_specification/generated/array_api.linspace.html

rgommers commented 11 months ago

This doesn't look like a very useful failure, and I don't think the answer is required to be -0.0. I suggest avoiding the use of -0.0 or check with an assert function that has behavior like:

>>> -0.0 == 0.0
True