Skip to content

Make special case tests only use relevant arrays #40

Closed
@honno

Description

@honno

Right now we generate arrays irrelevant to test cases, e.g. arrays with no NaNs in a test case about NaN behaviour. A low-priority thing is to generate test cases which are relevant to the test case (either by xps.arrays(..., elements={...}) or xps.arrays(...).filter(...)). Probably requires some significant reworking of generate_stubs.py.

To quote myself from #38:

It seems like the only problem with numpy.array_api (when running 2000 examples) is in-place addition.

>>> x1 = xp.asarray(-0.0)
>>> x1
Array(-0., dtype=float64)
>>> x2 = xp.asarray(-0.0)
>>> xp.add(x1, x2)
Array(-0., dtype=float64)
>>> x1 + x2
Array(-0., dtype=float64)
>>> x1 += x2
>>> x1
Array(0., dtype=float64)  # not negative 0, like it is with xp.add() and __add__()

Interestingly I had to run like 200 examples to get this error consistently. Something for the future would be to filter strategies from the @given() level so that only arrays with NaNs/infs/whateverproperty-we're-testing are generated, which would mitigate this problem.

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