From eefc0a00c6373671eb9c42707c9a3a6599174064 Mon Sep 17 00:00:00 2001 From: Jacob Burnim Date: Mon, 11 Mar 2024 04:46:30 +0000 Subject: [PATCH] More Python 3.12 fixes. --- tensorflow_probability/python/bijectors/bijector_test.py | 6 +++--- .../distributions/joint_distribution_coroutine_test.py | 2 +- .../python/mcmc/metropolis_hastings_test.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tensorflow_probability/python/bijectors/bijector_test.py b/tensorflow_probability/python/bijectors/bijector_test.py index 2d87e67daa..fa93ed77f2 100644 --- a/tensorflow_probability/python/bijectors/bijector_test.py +++ b/tensorflow_probability/python/bijectors/bijector_test.py @@ -56,9 +56,9 @@ class BaseBijectorTest(test_util.TestCase): """Tests properties of the Bijector base-class.""" def testIsAbstract(self): - with self.assertRaisesRegexp(TypeError, - ('Can\'t instantiate abstract class Bijector ' - 'with abstract methods? __init__')): + with self.assertRaisesRegex(TypeError, + ('Can\'t instantiate abstract class Bijector ' + 'with.* abstract methods? \'?__init__')): bijector_lib.Bijector() # pylint: disable=abstract-class-instantiated def testDefaults(self): diff --git a/tensorflow_probability/python/distributions/joint_distribution_coroutine_test.py b/tensorflow_probability/python/distributions/joint_distribution_coroutine_test.py index 2ad9a97275..68bdbd2a6f 100644 --- a/tensorflow_probability/python/distributions/joint_distribution_coroutine_test.py +++ b/tensorflow_probability/python/distributions/joint_distribution_coroutine_test.py @@ -1307,7 +1307,7 @@ def dist(): warnings.simplefilter('always') with warnings.catch_warnings(record=True) as w: d.sample(seed=test_util.test_seed()) - self.assertRegexpMatches( + self.assertRegex( str(w[0].message), r'Falling back to stateful sampling for distribution #1.*' r'of type.*StatefulNormal.*component name "loc" and `dist.name` ' diff --git a/tensorflow_probability/python/mcmc/metropolis_hastings_test.py b/tensorflow_probability/python/mcmc/metropolis_hastings_test.py index 0aa4f278ff..59a2f179af 100644 --- a/tensorflow_probability/python/mcmc/metropolis_hastings_test.py +++ b/tensorflow_probability/python/mcmc/metropolis_hastings_test.py @@ -385,10 +385,10 @@ def testWarnings(self): _, _ = mh.one_step(current_state, init_kernel_results, seed=test_util.test_seed()) w = sorted(w, key=lambda w: str(w.message)) - self.assertRegexpMatches( + self.assertRegex( str(w[0].message), r'`TransitionKernel` is already calibrated') - self.assertRegexpMatches( + self.assertRegex( str(w[1].message), r'`TransitionKernel` does not have a `log_acceptance_correction`')