Skip to content

Commit

Permalink
[NumPy] Remove references to deprecated NumPy type aliases.
Browse files Browse the repository at this point in the history
This change replaces references to a number of deprecated NumPy type aliases (np.bool, np.int, np.float, np.complex, np.object, np.str) with their recommended replacement (bool, int, float, complex, object, str).

NumPy 1.24 drops the deprecated aliases, so we must remove uses before updating NumPy.

PiperOrigin-RevId: 501824360
  • Loading branch information
hawkinsp authored and evcu committed Jan 26, 2023
1 parent 8ec3175 commit d39fc7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions rigl/experimental/jax/datasets/cifar10_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_train_image_dims_content(self):
self.assertTupleEqual(image.shape, (self._batch_size, 32, 32, 3))

with self.subTest(name='DataType'):
self.assertTrue(np.issubdtype(image.dtype, np.float))
self.assertTrue(np.issubdtype(image.dtype, float))

with self.subTest(name='DataValues'):
# Normalized by stddev., expect nothing to fall outside 3 stddev.
Expand All @@ -59,7 +59,7 @@ def test_train_image_dims_content(self):
self.assertLen(label, self._batch_size)

with self.subTest(name='LabelType'):
self.assertTrue(np.issubdtype(label.dtype, np.int))
self.assertTrue(np.issubdtype(label.dtype, int))

with self.subTest(name='LabelValues'):
self.assertTrue((label >= 0).all() and
Expand All @@ -75,7 +75,7 @@ def test_test_image_dims_content(self):
self.assertTupleEqual(image.shape, (self._batch_size_test, 32, 32, 3))

with self.subTest(name='DataType'):
self.assertTrue(np.issubdtype(image.dtype, np.float))
self.assertTrue(np.issubdtype(image.dtype, float))

with self.subTest(name='DataValues'):
# Normalized by stddev., expect nothing to fall outside 3 stddev.
Expand All @@ -85,7 +85,7 @@ def test_test_image_dims_content(self):
self.assertLen(label, self._batch_size_test)

with self.subTest(name='LabelType'):
self.assertTrue(np.issubdtype(label.dtype, np.int))
self.assertTrue(np.issubdtype(label.dtype, int))

with self.subTest(name='LabelValues'):
self.assertTrue((label >= 0).all() and
Expand Down
8 changes: 4 additions & 4 deletions rigl/experimental/jax/datasets/mnist_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def test_train_image_dims_content(self):
self.assertTrue((image >= -1.).all() and (image <= 1.).all())

with self.subTest(name='data_type'):
self.assertTrue(np.issubdtype(image.dtype, np.float))
self.assertTrue(np.issubdtype(image.dtype, float))

with self.subTest(name='label_shape'):
self.assertLen(label, self._batch_size)

with self.subTest(name='label_type'):
self.assertTrue(np.issubdtype(label.dtype, np.int))
self.assertTrue(np.issubdtype(label.dtype, int))

with self.subTest(name='label_values'):
self.assertTrue((label >= 0).all() and
Expand All @@ -74,7 +74,7 @@ def test_test_image_dims_content(self):
self.assertTupleEqual(image.shape, (self._batch_size_test, 28, 28, 1))

with self.subTest(name='data_type'):
self.assertTrue(np.issubdtype(image.dtype, np.float))
self.assertTrue(np.issubdtype(image.dtype, float))

# TODO: Find a better approach to testing with JAX arrays.
with self.subTest(name='data_values'):
Expand All @@ -84,7 +84,7 @@ def test_test_image_dims_content(self):
self.assertLen(label, self._batch_size_test)

with self.subTest(name='label_type'):
self.assertTrue(np.issubdtype(label.dtype, np.int))
self.assertTrue(np.issubdtype(label.dtype, int))

with self.subTest(name='label_values'):
self.assertTrue((label >= 0).all() and
Expand Down

0 comments on commit d39fc7d

Please sign in to comment.