Skip to content

Commit 0e11587

Browse files
lingvo-botcopybara-github
authored andcommitted
[numpy] Fix users of NumPy APIs that are removed in NumPy 2.0.
This change migrates users of APIs removed in NumPy 2.0 to their recommended replacements (https://numpy.org/devdocs/numpy_2_0_migration_guide.html). PiperOrigin-RevId: 656475023
1 parent d0bd551 commit 0e11587

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lingvo/core/layers_test.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -5495,7 +5495,10 @@ def testDeterministicDropoutLayer(self):
54955495
np.isclose(x_val, 0.0), np.isclose(x_val, 1.0 / 0.7))))
54965496
# Check that values contain 0 but are not all 0.
54975497
self.assertTrue(
5498-
0 < np.sum(np.cast[np.int32](np.isclose(x_val, 0.0))) < x_val.size)
5498+
0
5499+
< np.sum(np.asarray(np.isclose(x_val, 0.0), dtype=np.int32))
5500+
< x_val.size
5501+
)
54995502

55005503
# Different step seed gives different result.
55015504
x_val = self.evaluate(dropout.FPropDefaultTheta(x))
@@ -5555,7 +5558,10 @@ def testNoiseShapeBroadcastDims(self):
55555558
1.0 / 0.7))))
55565559
# Check that values contain 0 but are not all 0.
55575560
self.assertTrue(
5558-
0 < np.sum(np.cast[np.int32](np.isclose(x_val, 0.0))) < x_val.size)
5561+
0
5562+
< np.sum(np.asarray(np.isclose(x_val, 0.0), dtype=np.int32))
5563+
< x_val.size
5564+
)
55595565
# Check that each row has the same value.
55605566
self.assertAllClose(np.broadcast_to(x_val[:, :1], x_val.shape), x_val)
55615567

0 commit comments

Comments
 (0)