From 42bb0b3904e493e825935ae69b1671f8d7c3351a Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 14 Jan 2019 08:59:09 -0200 Subject: [PATCH 1/2] Use a.item() instead of deprecated np.asscalar(a) np.asscalar() has been deprecated in numpy 1.16: https://github.com/numpy/numpy/blob/master/doc/release/1.16.0-notes.rst#new-deprecations --- src/_pytest/python_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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): From 650474665244bc1715c5b4443bc6398ae2c2ebf4 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 14 Jan 2019 09:03:23 -0200 Subject: [PATCH 2/2] Add CHANGELOG entry for #4643 --- changelog/4643.trivial.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/4643.trivial.rst 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.``.