Skip to content

Recommend np.testing module instead of pytest.approx with Numpy arrays #8337

@Zac-HD

Description

@Zac-HD

Via #8335 (comment), this issue proposes that we should deprecate pytest.approx() for numpy.ndarrays in favor of the numpy.testing module. That module is custom-built with lots of useful assertion helpers for Numpy, while pytest.approx() only incidentally copes with multi-dimensional arrays and the risk of treating arrays as truthy booleans in assertions.

I particularly like this because we can very easily check if something is an array without importing Numpy, and teaching people about the numpy.testing module is likely to lead to better tests 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: approxrelated to pytest.approx functiontype: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions