-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix: coerce unknown types to O dtype #10339
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
base: main
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
|
do you think we could add a quick comment in the code describing what it's doing, for the less informed of us? (does anyone know this better?) |
|
Sure, done. Another options for this would be to check all the args passed to the |
|
@keewis is there any timeline for this to be reviewed? We're currently stuck with xarray v2024.2.0 as a dependency until this is resolved which is starting to cause issues when used in some working environments. |
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, this had completely dropped off my radar.
If this is about scalars, note that you can already wrap your custom object in a 0D array of object dtype to work around this (so you don't have to wait on us)
@shoyer, do you have an opinion on this?
shoyer
left a comment
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.
Let's get this in after applying @keewis's suggested clean-up?
Co-authored-by: Justus Magin <[email protected]>
for more information, see https://pre-commit.ci
|
yeah, I thought I'd help you fix the untested parts of what I suggested |
Added a check for Python objects that neither have numpy dtype
dtypeattributes nor are one of the builtin types so that type promotion succeeds and defaults toobjectdtype.This deals with cases where user-defined instances are in the array which would otherwise trip up
numpy.result_type.I did think about placing this in
xarray.core.dtypes.preprocess_typesbut chose to place it closest to where it causes issues (namely, on callingxp.result_type).sumto custom object arrays withmin_count=1if n_dims <= sum_dims #9755whats-new.rstapi.rst