Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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