uxarray type dropped during `xr.Dataset + UxDataArray` and `ufunc(xr.DataArray, UxDataset)`
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
Línea de trabajo
Run the provided MCVE for the three mixed xarray/uxarray cases and inspect xarray method dispatch together with NumPy array_ufunc handling. Determine the xarray hook needed for these operations to preserve UxDataset, then verify that all listed binary operations and ufunc examples return UxDataset.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version
v2026.09.1
How did you install UXarray?
Source
What happened?
Spinoff of #1685 and #1695 to track a few remaining difficult-to-solve cases, which should now be considered out of scope for those issues. Results from binary operations with one xarray object and one uxarray object, when one is a Dataset and the other is a DataArray, currently do not always return a UxDataset (but they should).
(Workaround for any users encountering this bug: explicitly cast objects to uxarray types before or after performing the operation.)
These cases are:
xr.Dataset * UxDataArray, where * can be any binary operation (e.g. multiplication, addition, subtraction)ufunc(xr.Dataset, UxDataArray), where ufunc can be any numpy binary ufunc (e.g.np.minimum,np.divmod)ufunc(xr.DataArray, UxDataset), where ufunc can be any numpy binary ufunc (e.g.np.minimum,np.divmod)
In the docstring of test_nondestructive_binary_ops_and_binary_ufuncs_output_types() in #1767, these cases map to:
- case (K)
- also case (K)
- case (J)
All of these issues cannot be fixed in uxarray directly. Rather, to get these properly fixed would require editing xarray directly to, at minimum, provide a hook which subclasses can use in these cases.
(1) cannot be fixed in uxarray directly because the operation goes directly to xr.Dataset's methods, and when xr.Dataset sees that the second term is an instance of xr.DataArray it decides to handle everything, without giving the second term a chance to alter the behavior in any way.
(2) and (3) cannot be fixed in uxarray directly because numpy's __array_ufunc__ sees that the first term is not a subclass of the second term (or vice versa), so it starts trying to apply __array_ufunc__ in order of inputs. This leads to applying the xarray object's __array_ufunc__, which similarly decides to handle everything after seeing that the second term is an instance of an xarray object (xr.DataArray in (2); xr.Dataset in (3)), without giving the second term a chance to alter the behavior in any way.
What did you expect to happen?
I expected these cases to all return objects with type UxDataset.
Can you provide a MCVE to repoduce the bug?
import numpy as np
import uxarray as ux
uxds = ux.tutorial.open_dataset('quad-hexagon')
uxda = uxds['t2m']
xrds = uxds.to_xarray()
xrda = uxda.to_xarray()
# case 1
print(type(xrds * uxda)) # expected UxDataset, got xr.Dataset
# case 2
print(type(np.minimum(xrds, uxda))) # expected UxDataset, got xr.Dataset
# case 3
print(type(np.maximum(xrda, uxds))) # expected UxDataset, got xr.Dataset
- Lenguaje dominante
- Python
- Estrellas
- 230
- Forks
- 56
- Merge medio
- 6 d 14 h
- PR fusionados (30 d)
- 12
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de UXARRAY/uxarray
-
Update installation docs to include new conda recipesPosiblemente ocupada @Sevans711 la tomó hace 10 días. Abiertodocumentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
UXARRAY/uxarray#1793 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
developer experience
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Los mantenedores suelen responder en 2 días
-
zonal_mean() and weighted_mean() should return the same type of objectPosiblemente ocupada @Sevans711 la tomó hace 19 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
UXARRAY/uxarray#1733 · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 2 días
-
CI
Dificultad 4/5 3-5 días Aptitud para principiantes 15/100
Los mantenedores suelen responder en 2 días
Todos los issues de UXARRAY/uxarray
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
NousResearch/hermes-agent#136483 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
[BUG] LazyStackedTensorDictStore zeroes the last byte of a new key set on the last elementPosiblemente ocupada @peterdsharpe la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
pytorch/tensordict#2307 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
GrokModel.generate/a_generate pass an OpenAI-style list-of-dicts to xai_sdk.chat.user(), so every call crashes with a protobuf TypeError before any network I/OPosiblemente ocupada @Christian-Sidak la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
confident-ai/deepeval#3436 · 1 comentario ·
Los mantenedores suelen responder en 1 día