-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
type: bugproblem that needs to be addressedproblem that needs to be addressed
Description
Consider the following example comparing two multidimensional arrays using approx:
from pytest import approx
import numpy as np
def test_something():
shape = (5,4)
X = np.ones(shape)
Y = np.ones(shape)*2
assert X==approx(Y)
The error thrown by PyTest is:
E assert array([[1., 1., 1., 1.],\n [1., 1., 1., 1.],\n [1., 1., 1., 1.],\n [1., 1., 1., 1.],\n [1., 1., 1., 1.]]) == <[TypeError("only size-1 arrays can be converted to Python scalars") raised in repr()] ApproxNumpy object at 0x7f63bda42a58>
E + where <[TypeError("only size-1 arrays can be converted to Python scalars") raised in repr()] ApproxNumpy object at 0x7f63bda42a58> = approx(array([[2., 2., 2., 2.],\n [2., 2., 2., 2.],\n [2., 2., 2., 2.],\n [2., 2., 2., 2.],\n [2., 2., 2., 2.]]))
This is confusing since at first glance it seems that the problem is that I tried to convert some array in an inappropriate manner, while actually the assertion failed.
My PyTest version is 3.3.2.
Metadata
Metadata
Assignees
Labels
type: bugproblem that needs to be addressedproblem that needs to be addressed