Uh oh!
There was an error while loading. Please reload this page.
Add Index.should_add_coord_to_array - #10137
Conversation
... when check_default_indexes=False.
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.
Functions with a leading underscore are marked by pyright as unused if they are not used from within the module in which they are defined. Also remove unneeded nested import.
Move check_dataarray_coords in xarray.core.coordinates module and rename it to validate_dataarray_coords (name consistent with Index.validate_dataarray_coord). Move CoordinateValidationError from xarray.core.indexes to xarray.core.coordinates module.
benbovy
commented
Mar 18, 2025
Thanks @shoyer for taking a look! This is now ready for (another round of) review. Compared to #10116 this PR still represents a major data model change for DataArray (in the sense that it allows overriding strict enforcement of the DataArray model in certain cases), but I think that the risk is mitigated since it is here done explicitly via @dcherian regarding your #10116 (comment), in the example notebook the DataArray reprs shown without any list of dimensions for the Coordinates section do not strike me much. That said, the |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Yeah I think it could be improved, but certainly not a blocker here. IMO we can merge. I'm not a huge fan of the method name |
Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
dcherian
commented
Apr 24, 2025
Yeah this method's a hard one to name. The only thing that comes to mind is |
benbovy
commented
Apr 25, 2025
Another possible name: |
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.
dcherian
commented
Apr 28, 2025
I added suggestions for |
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.
* main: dev whats-new (pydata#10294) Add SeasonGrouper, SeasonResampler (pydata#9524) (fix): remove `PandasExtensionArray` from repr (pydata#10291) Do not rely on `np.broadcast_to` to perform trivial dimension insertion (pydata#10277) DOC: Remove reference to absolufy (pydata#10290) Fix for scalar detection (pydata#8821) Add Index.validate_dataarray_coord (pydata#10137) add redirect for contributing guide (pydata#10282) Update pre-commit hooks (pydata#10288) Adding xarray-eopf to ecosystem.rst (pydata#10289) Add public typing.py module (pydata#10215) Rename Twitter to X (pydata#10283) Add `xarray-lmfit` extension for curve fitting to ecosystem documentation (pydata#10262)
whats-new.rstapi.rstSame goal than #10116 using the alternative approach suggested in #10116 (comment) where the propagation (validation) of coordinates in a DataArray is delegated to their index (if any).
I find this approach cleaner than #10116. Here is the same notebook example adapted for this PR.
Index API alternatives
Index.validate_dataarray_coord(self, name: Hashable, var: Variable, dims: set[Hashable]) -> NoneIndex.validate_dataarray_coords(self, variables: dict[Hashable, Variable], dims: set[Hashable]) -> NoneIndexes.group_by_indexwhile in option 1 we simply need to iterate over_variables,_coordsand/or_indexes).Index.validate_dataarray_coords(self, variables: dict[Hashable, Variable], dims: set[Hashable]) -> CoordinatesOption 1, the simplest and working well with IntervalIndex, is currently implemented in this PR.
cc @shoyer@dcherian