-
Notifications
You must be signed in to change notification settings - Fork 92
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/onedimensional sigma #499
Fix/onedimensional sigma #499
Conversation
…handling of 1-dimensional kernel with size one
… one-dimensional sigma of size 1
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.
Looks good, thanks for the fix, I can confirm that my use case that originally caused this error is covered by this.
@@ -142,6 +146,13 @@ def __init__(self, sigma, invert=False): | |||
if not isinstance(sigma, pq.Quantity): | |||
raise TypeError("'sigma' must be a quantity") | |||
|
|||
if sigma.ndim > 0: | |||
# handle the one-dimensional case of size 1 | |||
if sigma.ndim == 1 & sigma.size == 1: |
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.
Just a side remark:
This will also catch something like sigma = [[5]] * pq.s
Seems fine to me though, since a meaningful error is raised in that case now.
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.
I assume that in the long run -- besides this not being Python -- we may want to have a more standard way to check types, and in particular the case of 0, 1 and 2 dimensional quantities
arrays.
This PR addresses Issue #455 .
Changes
typeError
ndim=1
,size = 1
withsigma = sigma[0]
Test
The following code snippet should no longer throw an error