Skip to content

Commit

Permalink
Ensure forward compatibility with Chex.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 414989400
  • Loading branch information
hbq1 authored and DistraxDev committed Dec 8, 2021
1 parent aaf22fb commit 888e456
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions distrax/_src/utils/equivalence.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,14 @@ def _test_raises_error(
self,
dist_args: Tuple[Any, ...] = (),
dist_kwargs: Optional[Dict[str, Any]] = None,
error_type=ValueError):
error_type=AssertionError):
"""Tests that the instantiation of the distribution raises an error."""
dist_kwargs = dist_kwargs or {}
with self.assertRaises(error_type):
self.distrax_cls(*dist_args, **dist_kwargs)
try:
with self.assertRaises(error_type):
self.distrax_cls(*dist_args, **dist_kwargs)
except ValueError:
# For forward compatibility with Chex (it will raise AssertionErrors
# instead of ValueErrors in the new version) .
# TODO(iukemaev): remove after the new version of Chex is released.
pass

0 comments on commit 888e456

Please sign in to comment.