Skip to content
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

Zero-dimensional arrays should be accepted as scalars #14

Open
burnpanck opened this issue Jun 16, 2016 · 2 comments
Open

Zero-dimensional arrays should be accepted as scalars #14

burnpanck opened this issue Jun 16, 2016 · 2 comments

Comments

@burnpanck
Copy link

Currently, zero-dimensional arrays get rejected on NumericalTrait(ndim=0), as the latter requires the value to be np.isscalar. Unfortunately np.isscalar(np.array(1)) == False. The error is particularly annoying in conjunction with quantities, as quantities.Quantity is a subclass of np.ndarray and thus it's instances are not numpy array scalars.

@astrofrog
Copy link
Owner

I agree, it would be nice for this to work. Would you be interested in contributing a patch?

@burnpanck
Copy link
Author

I have to admit that the validation code looks quite complicated to me (does it have to be that complicated?), so I do not want to mess too much with it. I think I have a fix that works though...

burnpanck added a commit to burnpanck/numtraits that referenced this issue Jun 16, 2016
burnpanck added a commit to burnpanck/numtraits that referenced this issue Jun 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants