diff --git a/dm_control/mujoco/index.py b/dm_control/mujoco/index.py index 112e4a78..6e7a4444 100644 --- a/dm_control/mujoco/index.py +++ b/dm_control/mujoco/index.py @@ -372,7 +372,7 @@ def convert_key_item(self, key_item): key_item = np.array([self._names_to_offsets[util.to_native_string(k)] for k in key_item.flat]) # Ensure the output shape is the same as that of the input. - key_item.shape = original_shape + key_item.reshape(original_shape) return key_item diff --git a/dm_control/mujoco/index_test.py b/dm_control/mujoco/index_test.py index 3eaeae53..96831241 100644 --- a/dm_control/mujoco/index_test.py +++ b/dm_control/mujoco/index_test.py @@ -348,7 +348,7 @@ def testReadWrite_(self, field): # Don't write to non-float fields since these might contain pointers. if np.issubdtype(old_contents.dtype, np.floating): new_contents = np.arange(old_contents.size, dtype=old_contents.dtype) - new_contents.shape = old_contents.shape + new_contents.reshape(old_contents.shape) field[:] = new_contents np.testing.assert_array_equal(new_contents, field[:]) diff --git a/dm_control/mujoco/wrapper/core_test.py b/dm_control/mujoco/wrapper/core_test.py index 3489f126..167bf2af 100644 --- a/dm_control/mujoco/wrapper/core_test.py +++ b/dm_control/mujoco/wrapper/core_test.py @@ -553,7 +553,7 @@ def _write_unique_values(self, attr_name, target_array): and not np.issubdtype(target_array.dtype, np.integer) and not np.issubdtype(target_array.dtype, np.bool_)): new_contents = np.arange(target_array.size, dtype=target_array.dtype) - new_contents.shape = target_array.shape + new_contents.reshape(target_array.shape) target_array[:] = new_contents np.testing.assert_array_equal(new_contents, target_array[:])