You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@climate.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2014/04/05 23:41:15 UTC

[jira] [Commented] (CLIMATE-399) Use functions in numpy.testing for unit tests involving array comparisons

    [ https://issues.apache.org/jira/browse/CLIMATE-399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13961249#comment-13961249 ] 

ASF GitHub Bot commented on CLIMATE-399:
----------------------------------------

GitHub user agoodm opened a pull request:

    https://github.com/apache/climate/pull/17

    CLIMATE-399 - Use functions in numpy.testing for unit tests involving array comparisons

    This should slightly improve the robustness of our unit tests involving numpy array equality.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/agoodm/climate CLIMATE-399

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/climate/pull/17.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #17
    
----
commit 6fc67954b6d1ecc85694397fad0765c18a2d94b7
Author: bassdx <ag...@gmail.com>
Date:   2014-04-05T21:34:06Z

    Use numpy.testing functions for array comparisons

----


> Use functions in numpy.testing for unit tests involving array comparisons
> -------------------------------------------------------------------------
>
>                 Key: CLIMATE-399
>                 URL: https://issues.apache.org/jira/browse/CLIMATE-399
>             Project: Apache Open Climate Workbench
>          Issue Type: Improvement
>          Components: general
>    Affects Versions: 0.3-incubating
>            Reporter: Alex Goodman
>            Assignee: Alex Goodman
>             Fix For: 0.4
>
>
> Currently our unit tests for numpy array equality look something like this:
> {code}
> self.assertTrue(np.arrray_equal(x, y))
> {code}
> which could raise the following exception:
> {code}
> AssertionError:
> False is not true
> {code}
> This indeed tells us if the test has failed, but it would be better if the output could show where the arrays were inconsistent. The functions included in numpy.testing fulfill this purpose, and are widely used in other projects depending on numpy arrays. Therefore we should replace all instances of the above example with:
> {code}
> np.testing.assert_array_equal(x, y)
> {code}
> Which could raise exceptions like:
> {code}
> AssertionError:
> Arrays are not equal
> (mismatch 100.0%)
>  x: array([ 1.        ,  3,         7])
>  y: array([ -2.        ,  -4,         -6])
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)