From ac33ee942254dd5f35e5a8eeff4492d405e3d0ae Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Fri, 5 Dec 2025 17:26:36 -0500 Subject: [PATCH 1/2] doc: add required variable to custom index --- doc/internals/how-to-create-custom-index.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/internals/how-to-create-custom-index.rst b/doc/internals/how-to-create-custom-index.rst index 351694fc62d..59cc0a983e2 100644 --- a/doc/internals/how-to-create-custom-index.rst +++ b/doc/internals/how-to-create-custom-index.rst @@ -172,11 +172,12 @@ regularly spaced 2-dimensional data) that internally relies on two self._xy_indexes = xy_indexes @classmethod - def from_variables(cls, variables): + def from_variables(cls, variables, *, options): assert len(variables) == 2 xy_indexes = { - k: PandasIndex.from_variables({k: v}) for k, v in variables.items() + k: PandasIndex.from_variables({k: v}, options=options) + for k, v in variables.items() } return cls(xy_indexes) From 8d9a29aac0ff52288e53fe9b6d0debe127452a92 Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Fri, 5 Dec 2025 18:53:06 -0500 Subject: [PATCH 2/2] execute --- doc/internals/how-to-create-custom-index.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/internals/how-to-create-custom-index.rst b/doc/internals/how-to-create-custom-index.rst index 59cc0a983e2..49d351511a5 100644 --- a/doc/internals/how-to-create-custom-index.rst +++ b/doc/internals/how-to-create-custom-index.rst @@ -154,7 +154,8 @@ Here is a small example of a meta-index for geospatial, raster datasets (i.e., regularly spaced 2-dimensional data) that internally relies on two ``PandasIndex`` instances for the x and y dimensions respectively: -.. code-block:: python +.. jupyter-execute:: + from xarray import Index from xarray.core.indexes import PandasIndex @@ -214,7 +215,7 @@ How to use a custom index You can use :py:meth:`Dataset.set_xindex` or :py:meth:`DataArray.set_xindex` to assign a custom index to a Dataset or DataArray, e.g., using the ``RasterIndex`` above: -.. code-block:: python +.. jupyter-execute:: import numpy as np import xarray as xr