Skip to content

Supporting arrays for approx #1994

Closed
Closed
@DerWeh

Description

@DerWeh

The current syntax of pytest.approx doesn't work good with arrays. np.allclose must be used to compare arrays.
In

def test_array():
    assert np.allclose(np.array([1., 2.]), np.array([1., 2.]))
    assert np.all(np.array([1., 2.]) == pytest.approx(np.array([1., 2.])))

the first assert evaluates to true, the second to false.
Something like

assert np.array([1., 2.]) == pytest.approx(np.array([1., 2.])) 

Would be the most intuitive if it worked, as it also works with lists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: help wanteddevelopers would like help from experts on this topictype: enhancementnew feature or API change, should be merged into features branchtype: feature-branchnew feature or API change, should be merged into features branchtype: refactoringinternal improvements to the code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions