-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: targetting and add shape to ndarray #891
base: main
Are you sure you want to change the base?
Conversation
Add documentation for cylinder targetting. fix minor typos in documentations
bsb/config/types.py
Outdated
if shape is not None: | ||
for dim in shape: | ||
if dim < 0: | ||
raise TypeError( | ||
f"Ndarray shape must all be positive. Provided {shape}." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if shape is not None: | |
for dim in shape: | |
if dim < 0: | |
raise TypeError( | |
f"Ndarray shape must all be positive. Provided {shape}." | |
) | |
if (shape or ()).any(lambda dim: dim < 0): | |
raise TypeError( | |
f"types.ndarray shape must all be positive. Provided {shape}." | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tuple does not have an any function but I kept the concept in my last commit.
bsb/config/types.py
Outdated
result = result.reshape(self.shape) | ||
except Exception: | ||
raise TypeError( | ||
"Couldn't cast {} into an array of shape {}".format(value, self.shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this going to give a really big message for really big arrays?
"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." |
Always prefer f-strings over .format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm value
might not be a ndarray but we can assume that it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh true, let me correct that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implemented in my last commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong button
Describe the work done
List which issues this resolves:
closes #890, #869
Tasks