Skip to content

numpy.testing.assert_allclose reports wrong mismatch % #2912

Closed

Description

@callegar

numpy.testing.assert_allclose([1,2,3],[1,2.01,3]) returns

mismatch 100.0%

numpy.testing.assert_almost_equal([1,2,3],[1,2.01,3]) correctly returns

mismatch 33%

Activity

  1. rgommers commented on Jan 14, 2013

    @rgommers
    Member

    Hmm, never noticed this before. np.allclose only returns True or False, so on failure the test will always say 100% mismatch.

  2. njsmith commented on Jan 14, 2013

    @njsmith
    Member

    So is the solution just to change assert_allclose so it doesn't report a
    percentage? (I find the percentages pretty distracting anyway honestly.)

    On Mon, Jan 14, 2013 at 8:10 PM, Ralf Gommers [email protected]:

    Hmm, never noticed this before. np.allclose only returns True or False,
    so on failure the test will always say 100% mismatch.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/2912#issuecomment-12237195.

  3. rgommers commented on Jan 14, 2013

    @rgommers
    Member

    All assert_ functions use the same function under the hood (assert_array_compare) so fixing the percentage by not using np.allclose would be cleaner than special-casing assert_allclose I think.

    Although it would involve some code duplication by lifting some lines from allclose into assert_allclose. Nothing's perfect.....

  4. jorisvandenbossche commented on Mar 24, 2015

    @jorisvandenbossche
    Contributor

    I think this issue can be closed as #5025 is intended to have fixed this?

  5. rgommers commented on Mar 25, 2015

    @rgommers
    Member

    Indeed, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions