Uh oh!
There was an error while loading. Please reload this page.
Align casting methods with Python behaviour - #497
Conversation
Uh oh!
There was an error while loading. Please reload this page.
x.__complex__(), unrestrict cross-kind casting in respective array methodsPer what we decided upon in our last array meeting (see #486 (comment)), I've updated this PR with my take on how to we align the spec's casting methods with Python's behaviour. I have some thorough testing for how Python's casting works in https://gist.github.com/honno/98371048b4d5b9fc4a003377a714e827, which I'll have to tidy up (will be useful anyway for the test suite). As @seberg noted, NumPy seems to 100% follow Python casting behaviour for its arrays (if we're not including a small divergence in behaviour for NumPy scalars). Only notable thing maybe is NumPy not aligning with Python's Not 100% on language used, happy to hear what folk think. Will sleep on it anyway. |
honno
left a comment
There was a problem hiding this comment.
Just realised I should probably special case non-finite values for __bool__.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
honno
commented
Nov 14, 2022
Think this is ready @seberg@asmeurer? With the follow up of specifying |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Athan <kgryte@gmail.com>
honno
commented
Nov 15, 2022
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
kgryte
commented
Dec 14, 2022
I believe all discussion points have been resolved. I'll go ahead and merge. Any further changes can be addressed in follow-up PRs. Thanks, all! |
Resolves#486 (adding
x.__complex__()).Per interest in having the builtin casting methods (
__bool__/__int__/__float__/__complex__/__index__) support arrays of a different dtype kind, this PR also changes the language to clarify that adopters can support such casting. EDIT: now aligning casting methods with Python behaviour generally(I opted against requiring cross-kind casting in this PR—see #486 (comment))See #486 (comment)