Skip to content

Commit e3a2483

Browse files
hawkinspcopybara-github
authored andcommitted
[numpy] Replace uses of np.in1d with np.isin(...).ravel().
np.in1d is removed in NumPy 2.4. PiperOrigin-RevId: 840207834 Change-Id: I27dcc518ed3325515001ec965af12e4c81928acc
1 parent 830a3c9 commit e3a2483

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

dm_control/composer/initializers/tcp_initializer_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ def assertEntitiesInContact(self, physics, first, second):
5353
second_geom_ids = physics.bind(
5454
second.mjcf_model.find_all('geom')).element_id
5555
contact = physics.data.contact
56-
first_to_second = (np.in1d(contact.geom1, first_geom_ids) &
57-
np.in1d(contact.geom2, second_geom_ids))
58-
second_to_first = (np.in1d(contact.geom1, second_geom_ids) &
59-
np.in1d(contact.geom2, first_geom_ids))
56+
first_to_second = (np.isin(contact.geom1, first_geom_ids).ravel() &
57+
np.isin(contact.geom2, second_geom_ids).ravel())
58+
second_to_first = (np.isin(contact.geom1, second_geom_ids).ravel() &
59+
np.isin(contact.geom2, first_geom_ids).ravel())
6060
touching = contact.dist <= 0
6161
valid_contact = touching & (first_to_second | second_to_first)
6262
self.assertTrue(np.any(valid_contact), msg='Entities are not in contact.')

dm_control/suite/quadruped.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ def _get_sensor_names(self, *sensor_types):
155155
try:
156156
sensor_names = self._sensor_types_to_names[sensor_types]
157157
except KeyError:
158-
[sensor_ids] = np.where(np.in1d(self.model.sensor_type, sensor_types))
158+
[sensor_ids] = np.where(
159+
np.isin(self.model.sensor_type, sensor_types).ravel()
160+
)
159161
sensor_names = [self.model.id2name(s_id, 'sensor') for s_id in sensor_ids]
160162
self._sensor_types_to_names[sensor_types] = sensor_names
161163
return sensor_names

0 commit comments

Comments
 (0)