uxarray type dropped during `xr.Dataset + UxDataArray` and `ufunc(xr.DataArray, UxDataset)`
Maintainer antworten meist innerhalb von 3 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Python
- Sterne
- 231
- Forks
- 58
- Ø Merge
- 6 T. 7 Std.
- Gemergte PRs (30 T.)
- 9
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus UXARRAY/uxarray
-
Update installation docs to include new conda recipesEvtl. vergeben @Sevans711 hat das vor 24 Tagen übernommen. Offendependencies documentation
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
UXARRAY/uxarray#1793 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 3 Tagen
-
developer experience
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
Maintainer antworten meist innerhalb von 3 Tagen
-
zonal_mean() and weighted_mean() should return the same type of objectEvtl. wieder frei @Sevans711 hat das vor 33 Tagen übernommen, und es ist kein Pull Request offen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
UXARRAY/uxarray#1733 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 3 Tagen
-
documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 3 Tagen
-
`azimuthal_mean` builds a full subgrid for every ringEvtl. vergeben @cmdupuis3 hat das vor 1 Tag übernommen. Offen
UXARRAY/uxarray#1848 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 3 Tagen
Alle Issues in UXARRAY/uxarray
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
conda-forge/conda-forge-bot#7025 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:ci
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 74/100
catincloud-labs/dagster-dex#149 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
home-assistant/core#188424 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Review backlog (docs-currency): README 'CI run' link lands on a run whose overall badge is cancelledOffenagent/reviewer needs-kind needs-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 63/100
projectbluefin/utah#880 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
redis/memtier_benchmark#850 ·
Maintainer antworten meist innerhalb von 1 Tag