You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@climate.apache.org by "Alex Goodman (JIRA)" <ji...@apache.org> on 2014/04/07 01:08:14 UTC

[jira] [Resolved] (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:all-tabpanel ]

Alex Goodman resolved CLIMATE-399.
----------------------------------

    Resolution: Fixed

PR Merged

> 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)