MAINT: Change the Scalar check in astype to only accept np objects#31369
MAINT: Change the Scalar check in astype to only accept np objects#31369mncrftfrcnm wants to merge 3 commits into
Conversation
|
I don’t think changing the astype implementation is correct, instead we should do a try/except (or the equivalent in C if the the getattr is happening in C) and raise the appropriate error at the site where it happens. Generally it’s best to open issues about bugs you find before sending in a PR with a fix, particularly for projects you’re new to the internals of. |
So, should i do smt like this: |
Also, if I did everything correctly, it will only omit the python native scalars, returning proper error, which is what the previous reviewer asked for in the other PR, where I implemented python-native scalar handling(here's link to that PR: #31365 ) |
ok, i've changed the way it handles attribute error to try_except |
PR summary
So, the issue i found was in the astype function. This PR updates 'np.astype':, so python scalar inputs return attribute error, instead of ending with error 'AttributeError', which is not entirely correct
here is what the fixed version looks like, instead of attribute error
(error message edited a bit, so only the final error message is shown, omiting all other details, like: 'Traceback (most recent call last):
File "", line 1, in ')
here is what original original function output looked like:
First time committer introduction
I use numpy as a machine learner, and data-analytic. I also use it for a lot of other tasks, but primarily for ML.
I was interested in reviewing the code of numpy, and how it works, and i saw a bug in astype.
AI Disclosure
No AI tools used