[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
This commit is contained in:
parent
6718ae2636
commit
857fe8f482
1 changed files with 2 additions and 2 deletions
|
@ -190,7 +190,7 @@ def rdp_gaussian(logq, sigma, orders):
|
||||||
assert np.all(ret >= 0)
|
assert np.all(ret >= 0)
|
||||||
|
|
||||||
if np.isscalar(orders):
|
if np.isscalar(orders):
|
||||||
return np.asscalar(ret)
|
return ret.item()
|
||||||
else:
|
else:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ def rdp_pure_eps(logq, pure_eps, orders):
|
||||||
np.minimum(0.5 * pure_eps * pure_eps * orders_vec,
|
np.minimum(0.5 * pure_eps * pure_eps * orders_vec,
|
||||||
log_t / (orders_vec - 1)), pure_eps)
|
log_t / (orders_vec - 1)), pure_eps)
|
||||||
if np.isscalar(orders):
|
if np.isscalar(orders):
|
||||||
return np.asscalar(ret)
|
return ret.item()
|
||||||
else:
|
else:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue