Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions dm_control/mujoco/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,9 @@ def convert_key_item(self, key_item):
# representing names. If there is a mix, we will let NumPy throw an error
# when trying to index with the returned item.
if isinstance(key_item.flat[0], str):
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 = np.array(
[self._names_to_offsets[util.to_native_string(k)] for k in key_item.flat]
).reshape(original_shape) # Ensure the output shape is the same as that of the input.

return key_item

Expand Down
5 changes: 3 additions & 2 deletions dm_control/mujoco/index_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,9 @@ def testReadWrite_(self, field):
# Write unique values to the FieldIndexer and read them back again.
# 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 = np.arange(
old_contents.size, dtype=old_contents.dtype
).reshape(old_contents.shape)
field[:] = new_contents
np.testing.assert_array_equal(new_contents, field[:])

Expand Down
5 changes: 3 additions & 2 deletions dm_control/mujoco/wrapper/core_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,9 @@ def _write_unique_values(self, attr_name, target_array):
elif (attr_name != "stack"
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 = np.arange(
target_array.size, dtype=target_array.dtype
).reshape(target_array.shape)
target_array[:] = new_contents
np.testing.assert_array_equal(new_contents, target_array[:])

Expand Down