Alex Goodman created CLIMATE-399:
------------------------------------

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

Reply via email to