Skip to content

changed asscalar to pass through scalars #5126

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

Closed
wants to merge 2 commits into from

Conversation

jarl-haggerty
Copy link
Contributor

return a.item()
try:
return a.item()
except AttributeError as e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just plain old except AttributeError: will work fine, you don't make any use of e.

@charris
Copy link
Member

charris commented Oct 18, 2014

Hmm, the function is documented to work with arrays of size 1, but not with scalars. It is not clear what we should do in the case of scalars, although your fix looks as good as any. The two commits should be squashed into one.

@charris
Copy link
Member

charris commented Feb 17, 2015

I think it best to leave the function as is. One thing that could be done is check for array of size == 1 and raise a more informative error message, but the function is not used anywhere in numpy and not tested, so probably not very important. Straight use of a.item() might be preferable to using the function.

The function has no test, so if you want to submit a PR with a test, that would be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants