diff --git a/changelog/4643.trivial.rst b/changelog/4643.trivial.rst new file mode 100644 index 000000000..75385f4b3 --- /dev/null +++ b/changelog/4643.trivial.rst @@ -0,0 +1,3 @@ +Use ``a.item()`` instead of the deprecated ``np.asscalar(a)`` in ``pytest.approx``. + +``np.asscalar`` has been `deprecated `__ in ``numpy 1.16.``. diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 4e4740192..9b31d4e68 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -150,10 +150,10 @@ class ApproxNumpy(ApproxBase): if np.isscalar(actual): for i in np.ndindex(self.expected.shape): - yield actual, np.asscalar(self.expected[i]) + yield actual, self.expected[i].item() else: for i in np.ndindex(self.expected.shape): - yield np.asscalar(actual[i]), np.asscalar(self.expected[i]) + yield actual[i].item(), self.expected[i].item() class ApproxMapping(ApproxBase):