Skip to content

Commit

Permalink
Fix exception context in BoundedArray.__init__
Browse files Browse the repository at this point in the history
  • Loading branch information
cool-RR committed Mar 11, 2021
1 parent 09686eb commit 7478092
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dm_env/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 7478092

Please sign in to comment.