Skip to content

Commit

Permalink
[NumPy] Replace numpy.asscalar(x) with x.item() in preparation for up…
Browse files Browse the repository at this point in the history
…grading 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: 466151898
  • Loading branch information
hawkinsp authored and Copybara-Service committed Aug 8, 2022
1 parent 99e9784 commit 78d2b6e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion trax/tf_numpy/numpy_impl/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def __index__(self):
ValueError: If the array does not have size 1.
"""
# TODO(wangpeng): Handle graph mode
return np.asscalar(self.data.numpy())
return self.data.numpy().item()

def tolist(self):
return self.data.numpy().tolist()
Expand Down

0 comments on commit 78d2b6e

Please sign in to comment.