diff --git a/xarray/core/indexes.py b/xarray/core/indexes.py index 43e231e84d4..22febf0b707 100644 --- a/xarray/core/indexes.py +++ b/xarray/core/indexes.py @@ -209,7 +209,7 @@ def to_pandas_index(self) -> pd.Index: def isel( self, indexers: Mapping[Any, int | slice | np.ndarray | Variable] - ) -> Self | None: + ) -> Index | None: """Maybe returns a new index from the current index itself indexed by positional indexers. @@ -304,7 +304,7 @@ def reindex_like(self, other: Self) -> dict[Hashable, Any]: """ raise NotImplementedError(f"{self!r} doesn't support re-indexing labels") - def equals(self, other: Self) -> bool: + def equals(self, other: Index) -> bool: """Compare this index with another index of the same type. Implementation is optional but required in order to support alignment. @@ -1424,7 +1424,7 @@ def create_variables( def isel( self, indexers: Mapping[Any, int | slice | np.ndarray | Variable] - ) -> Self | None: + ) -> Index | None: # TODO: support returning a new index (e.g., possible to re-calculate the # the transform or calculate another transform on a reduced dimension space) return None @@ -1486,7 +1486,9 @@ def sel( return IndexSelResult(results) - def equals(self, other: Self) -> bool: + def equals(self, other: Index) -> bool: + if not isinstance(other, CoordinateTransformIndex): + return False return self.transform.equals(other.transform) def rename(