Repository navigation
ENH: add timedelta64 support boolean division and floor - #32555
Conversation
|
Nice minimal fix. The test failures in the CI run are unrelated breakage on canonical's infrastructure. This needs a release note. I also think this impacts the type stubs (cc @jorenham). It's probably also worth adding test cases for numpy booleans ( |
Right now the stubs already accept Lines 12881 to 12916 in 88ddb98 |
|
@ngoldbaum thanks for your feedback. I just added release note. |
Co-authored-by: Nathan Goldbaum <[email protected]>
ngoldbaum
left a comment
There was a problem hiding this comment.
Thanks! Someone else will need to give this a look and merge it but this looks good to me.
ngoldbaum
left a comment
There was a problem hiding this comment.
Oh sorry, I missed that you still need to update the type stubs. Joren can probably help if you get stuck there.
jorenham
left a comment
There was a problem hiding this comment.
Stub changes look good.
I have some minor suggestions to simplify things a bit, because these unions now coincide with the existing _FloatLike_co and _IntLike_co type aliases:
numpy/numpy/_typing/_scalars.py
Lines 13 to 14 in ca30acf
Co-authored-by: Joren Hammudoglu <[email protected]>
Co-authored-by: Joren Hammudoglu <[email protected]>
Co-authored-by: Joren Hammudoglu <[email protected]>
Co-authored-by: Joren Hammudoglu <[email protected]>
Co-authored-by: Joren Hammudoglu <[email protected]>
I see. It looks much cleaner now. Thank you! |
Co-authored-by: Joren Hammudoglu <[email protected]>
|
Thank you! |
PR summary
This PR based on issue #18445. Initially
timedelta64only accept int##, iftimedelta64is divided by boolean value such asoutput:
I added condition in
ufunct_type_resolution.csoPyUFunc_DivisionTypeResolver()bool i s upcast to int64 (true=1, False=0).new output:
First time committer introduction
I'm new contributors and I joined previous community meeting maybe 1-2 month ago, and suggested to take a look at the old issues and see if the bug still exist. I want to contribute to NumPy to challenge myself to contribute large repository and I use NumPy almost everyday for my internship too.
AI Disclosure
I used opencode to help draft both the code fix, and the test. I reviewed, wrote, and ran the test with myself.