From 3c69c10ae262cf7cb6db1b4e1658809ba8846cef Mon Sep 17 00:00:00 2001 From: drodarie Date: Sat, 5 Oct 2024 14:53:38 +0200 Subject: [PATCH] fix: implement feedback from review. --- bsb/config/types.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/bsb/config/types.py b/bsb/config/types.py index 1f1b5743..ae183d48 100644 --- a/bsb/config/types.py +++ b/bsb/config/types.py @@ -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 @@ -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