Skip to content

Commit

Permalink
[NumPy] Fix uses of functions deprecated in NumPy 1.25.
Browse files Browse the repository at this point in the history
NumPy 1.25 deprecates a number of function aliases (https://github.com/numpy/numpy/releases/tag/v1.25.0rc1)

This change replaces uses of the deprecated names with their recommended replacements:
* `np.round_` -> `np.round`
* `np.product` -> `np.prod`
* `np.cumproduct` -> `np.cumprod`
* `np.sometrue` -> `np.any`
* `np.alltrue` -> `np.all`

The deprecated functions will issue a `DeprecationWarning` under NumPy 1.25, and will be removed in NumPy 2.0.

PiperOrigin-RevId: 538846040
  • Loading branch information
hawkinsp authored and copybara-github committed Jun 8, 2023
1 parent b1e38bf commit bb6687a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions android_env/wrappers/discrete_action_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(
self._parent_action_spec = self._env.action_spec()
self._assert_base_env()
self._action_grid = action_grid # [height, width]
self._grid_size = np.product(self._action_grid)
self._grid_size = np.prod(self._action_grid)
self._num_action_types = self._parent_action_spec['action_type'].num_values
self._redundant_actions = redundant_actions
self._noise = noise
Expand All @@ -58,9 +58,9 @@ def num_actions(self) -> int:
"""Number of discrete actions."""

if self._redundant_actions:
return np.product(self._action_grid) * self._num_action_types
return np.prod(self._action_grid) * self._num_action_types
else:
return np.product(self._action_grid) + self._num_action_types - 1
return np.prod(self._action_grid) + self._num_action_types - 1

def step(self, action: dict[str, int]) -> dm_env.TimeStep:
"""Take a step in the base environment."""
Expand Down

0 comments on commit bb6687a

Please sign in to comment.