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
Consider numpy
scalars and 0d arrays as scalars when padding
#9653
Conversation
Can one of the admins verify this patch? Admins can comment |
add to allowlist |
since I couldn't come up with a better way to test this, I decided to just add a new test that checks a bunch of different dtype / scalar or 0d array combinations for |
gentle ping. I think the failing tests are unrelated (some |
gentle ping. @jrbourbeau, this is ready for a review. |
gentle reminder that this PR is still waiting for a review (and the only actual change is a single line). It would be really great if this could be merged any time soon, because that would allow fixing a few bugs in downstream libraries (most notably |
Apologies for the lack of response @keewis. Taking another look now |
numpy
scalars and 0d arrays as scalars when padding
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.
Thanks @keewis -- this is in. Again, apologies for the delayed response
As discussed in #9645, this adds
getattr(pad_value, "ndim", None) == 0
to the condition that checks if the pad value is scalar.While implementing the code, I noticed that while 0d arrays are definitely not instances of
Number
, for numpy scalars this is a bit more tricky: scalars withint
/float
/complex
/timedelta64
dtypes are already considered as scalars (theisinstance
check evaluates toTrue
), whiledatetime64
,bool_
,str_
and probably others are not.As such, I'm not sure what the best way to test scalars would be. I'd be tempted to just write new tests specifically for
expand_pad_value
, but that might not fit the existing test strategy (which fordask.array.creation
seems to just check the high-level functions).pre-commit run --all-files