From 7478092bff49d4fddcc7dd91335883b01582b65b Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Thu, 11 Mar 2021 22:49:26 +0200 Subject: [PATCH] Fix exception context in `BoundedArray.__init__` --- dm_env/specs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dm_env/specs.py b/dm_env/specs.py index 66faf6c..ddc8902 100644 --- a/dm_env/specs.py +++ b/dm_env/specs.py @@ -207,14 +207,14 @@ def __init__(self, shape, dtype, minimum, maximum, name=None): try: bcast_minimum = np.broadcast_to(minimum, shape=shape) except ValueError as numpy_exception: - raise ValueError('minimum is not compatible with shape. ' - 'Message: {!r}.'.format(numpy_exception)) + raise ValueError('minimum is not compatible with shape. Message: ' + '{!r}.'.format(numpy_exception)) from numpy_exception try: bcast_maximum = np.broadcast_to(maximum, shape=shape) except ValueError as numpy_exception: - raise ValueError('maximum is not compatible with shape. ' - 'Message: {!r}.'.format(numpy_exception)) + raise ValueError('maximum is not compatible with shape. Message: ' + '{!r}.'.format(numpy_exception)) from numpy_exception if np.any(bcast_minimum > bcast_maximum): raise ValueError(_MINIMUM_MUST_BE_LESS_THAN_OR_EQUAL_TO_MAXIMUM.format(