From 857fe8f482be9a40211d6da7f615a78a895a9c05 Mon Sep 17 00:00:00 2001 From: Peter Hawkins Date: Wed, 10 Aug 2022 11:26:30 -0700 Subject: [PATCH] [NumPy] Replace numpy.asscalar(x) with x.item() in preparation for upgrading NumPy to 1.23. NumPy 1.23 removes numpy.asscalar() (https://numpy.org/doc/stable/release/1.23.0-notes.html#expired-deprecations), which has been deprecated since NumPy 1.16 (https://numpy.org/doc/stable/release/1.16.0-notes.html#new-deprecations). x.item() should be identical to the previous implementation of numpy.asscalar(x) in every way. PiperOrigin-RevId: 466743223 --- research/pate_2018/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/research/pate_2018/core.py b/research/pate_2018/core.py index 84c79dc..4abc9d0 100644 --- a/research/pate_2018/core.py +++ b/research/pate_2018/core.py @@ -190,7 +190,7 @@ def rdp_gaussian(logq, sigma, orders): assert np.all(ret >= 0) if np.isscalar(orders): - return np.asscalar(ret) + return ret.item() else: return ret @@ -357,7 +357,7 @@ def rdp_pure_eps(logq, pure_eps, orders): np.minimum(0.5 * pure_eps * pure_eps * orders_vec, log_t / (orders_vec - 1)), pure_eps) if np.isscalar(orders): - return np.asscalar(ret) + return ret.item() else: return ret