-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
DOC: document type promotion with Python types #27404
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
DOC: document type promotion with Python types #27404
Conversation
The reason for this behavior is that NumPy converts ``int`` to its default | ||
integer type, and uses that type for promotion: |
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.
Side note: I could not find good documentation on default integer/float/complex type besides the somewhat confusing https://numpy.org/devdocs/numpy_2_0_migration_guide.html#windows-default-integer; perhaps we could add a subsection somewhere in this file?
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.
Sorry, I was out while this happened. But would also value someone else's input here.
To me, this is a detail about result_type
. And I feel that it should be mentioned there mainly?
(It is also something that we probably should consider changing there!)
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.
The default types are documented in the list of types, I think. But, I suppose we could move the footnote about it up and just state the fact that the default is int64
on 64bit systems (which are most systems, so we use that).
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, I added a reference to the promotion list in 904a6f5. I also reworded the footnote slightly.
To me, this is a detail about result_type. And I feel that it should be mentioned there mainly?
(It is also something that we probably should consider changing there!)
Do you mean, should this whole subsection be moved to the result_type
doc, or just the default integer discussion?
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.
I was wondering about this whole addition. The reason is that I don't think we mention the syntax of result_type
to allow dtypes at all (which is the crux, int
here would ideally not be a dtype instance, but an abstract DType class/type. But result_tyee
uses np.dtype(int)
which does a silly guess at the default).
So I am wondering if adding it here just adds another layer of complexity that is mainly needed with result_type
. OTOH, explaining result_type
in more detail here could make sense...
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.
I see. Just as an additional wrinkle, promote_types also accepts int...
Thanks @matthiasdiener . |
cc @seberg.
Closes #27325.