Merge pull request #4643 from nicoddemus/asscalar-deprecated

Use a.item() instead of deprecated np.asscalar(a)
This commit is contained in:
Anthony Sottile 2019-01-14 07:36:13 -08:00 committed by GitHub
commit 5903f4596a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -0,0 +1,3 @@
Use ``a.item()`` instead of the deprecated ``np.asscalar(a)`` in ``pytest.approx``.
``np.asscalar`` has been `deprecated <https://github.com/numpy/numpy/blob/master/doc/release/1.16.0-notes.rst#new-deprecations>`__ in ``numpy 1.16.``.

View File

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