From 5bad0dbddded1578ce542605714bf8eb5b748cb0 Mon Sep 17 00:00:00 2001 From: Jake VanderPlas Date: Tue, 16 Jan 2024 12:14:59 -0800 Subject: [PATCH] TST: make searchsorted test compatible with NumPy 2.0 --- tests/lax_numpy_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/lax_numpy_test.py b/tests/lax_numpy_test.py index 29db81e3d24f..be59c031bccf 100644 --- a/tests/lax_numpy_test.py +++ b/tests/lax_numpy_test.py @@ -2548,11 +2548,15 @@ def testSearchsortedDtype(self): if config.enable_x64.value: out_int64 = jax.eval_shape(jnp.searchsorted, a_int64, v) self.assertEqual(out_int64.dtype, np.int64) - else: + elif jtu.numpy_version() < (2, 0, 0): with self.assertWarnsRegex(UserWarning, "Explicitly requested dtype int64"): with jtu.ignore_warning(category=DeprecationWarning, message="NumPy will stop allowing conversion.*"): out_int64 = jax.eval_shape(jnp.searchsorted, a_int64, v) + else: + with self.assertWarnsRegex(UserWarning, "Explicitly requested dtype int64"): + with self.assertRaisesRegex(OverflowError, "Python integer 2147483648 out of bounds.*"): + out_int64 = jax.eval_shape(jnp.searchsorted, a_int64, v) @jtu.sample_product( dtype=inexact_dtypes,