[Numpy-discussion] actual, desired versus x, y
Keith Goodman
kwgoodman at gmail.com
Thu Jun 3 13:12:26 EDT 2010
On Thu, Jun 3, 2010 at 10:07 AM, Keith Goodman <kwgoodman at gmail.com> wrote:
> Some of the numpy.testing assert functions call the input x and y,
> others call it actual and desired:
>
>>> actual = np.array([1+1j])
>>> desired = np.array([2+2j])
>
>>> assert_almost_equal(actual, desired)
> <snip>
> AssertionError: Items are not equal:
> ACTUAL: [ 1.+1.j]
> DESIRED: [ 2.+2.j]
>
>>> assert_almost_equal(actual.real, desired.real)
> <snip>
> (mismatch 100.0%)
> x: array([ 1.])
> y: array([ 2.])
>
> I like the actual and desired, helps me remember which is which.
>
> BTW: numpy.testing is very handy!
I think it would be easier to read the output if the x or actual was
on a separate line. Then the rows of the arrays would line up.
current:
(mismatch 62.5%)
x: array([[ 1., NaN, 2., NaN, NaN],
[ 2., 2., NaN, NaN, NaN],
[ 3., 4., 4., 1., NaN]])
y: array([[ 1., NaN, 1., NaN, NaN],
[ 2., 1., NaN, NaN, NaN],
[ 3., 3., 3., 2., NaN]])
suggested (but alignment will be lost unless you're reading this in a
fix width font):
(mismatch 62.5%)
x:
array([[ 1., NaN, 2., NaN, NaN],
[ 2., 2., NaN, NaN, NaN],
[ 3., 4., 4., 1., NaN]])
y:
array([[ 1., NaN, 1., NaN, NaN],
[ 2., 1., NaN, NaN, NaN],
[ 3., 3., 3., 2., NaN]])
More information about the NumPy-Discussion
mailing list