Skip to content

fix: replace deprecated ndarray.shape assignment (NumPy 2.5) - #546

Open
erensh27 wants to merge 1 commit into
google-deepmind:mainfrom
erensh27:fix/numpy-2.5-shape-assignment
Open

fix: replace deprecated ndarray.shape assignment (NumPy 2.5)#546
erensh27 wants to merge 1 commit into
google-deepmind:mainfrom
erensh27:fix/numpy-2.5-shape-assignment

Conversation

@erensh27

@erensh27 erensh27 commented Aug 9, 2026

Copy link
Copy Markdown

Fixes #540: setting the shape attribute of a NumPy array is deprecated in NumPy 2.5 (numpy/numpy#29536). Replace all x.shape = other usages with x = x.reshape(other):

  • dm_control/mujoco/index.py convert_key_item: the freshly built offset array is reshaped back to the input shape (same elements, same order — identical indexing behavior).
  • dm_control/mujoco/index_test.py and dm_control/mujoco/wrapper/core_test.py: test fixtures use the same pattern when writing unique values into fields.

No behavior change.

NumPy 2.5 deprecates setting the shape attribute on an array
(numpy/numpy#29536). Use ndarray.reshape instead:

- dm_control/mujoco/index.py: reshape the freshly built key array back
  to its original shape.
- index_test.py / wrapper/core_test.py: reshape the synthetic contents
  arrays before comparing/writing.

The data layout is unchanged (same total element count, same order), so
indexing behavior is identical.
@google-cla

google-cla Bot commented Aug 9, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeprecationWarning: Setting the shape on a NumPy array has been deprecated in NumPy 2.5.

1 participant