Skip to content

Commit

Permalink
fix: implement feedback from review.
Browse files Browse the repository at this point in the history
  • Loading branch information
drodarie committed Oct 5, 2024
1 parent 64089db commit 3c69c10
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions bsb/config/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,12 +794,8 @@ def __init__(self, shape: builtins.tuple[builtins.int, ...] = None, dtype=None):
:param shape: shape of the array, optional.
:param dtype: data-type, optional
"""
if shape is not None:
for dim in shape:
if dim < 0:
raise TypeError(
f"Ndarray shape must all be positive. Provided {shape}."
)
if any(dim < 0 for dim in (shape or ())):
raise TypeError(f"Ndarray shape must all be positive. Provided {shape}.")
self.shape = shape
self.dtype = dtype

Expand All @@ -812,7 +808,7 @@ def __call__(self, value):
result = result.reshape(self.shape)
except Exception:
raise TypeError(
"Couldn't cast {} into an array of shape {}".format(value, self.shape)
f"Couldn't cast array of {getattr(value, 'shape', 'unknown')} shape into an array of {self.shape} shape."
)
return result

Expand Down

0 comments on commit 3c69c10

Please sign in to comment.