Skip to content

Commit 0f54b64

Browse files
committed
Remove CompatIndexedTuple
1 parent 0c86622 commit 0f54b64

File tree

1 file changed

+2
-36
lines changed

1 file changed

+2
-36
lines changed

xarray/core/indexing.py

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from dataclasses import dataclass, field
1111
from datetime import timedelta
1212
from html import escape
13-
from typing import TYPE_CHECKING, Any, Literal, overload
13+
from typing import TYPE_CHECKING, Any, overload
1414

1515
import numpy as np
1616
import pandas as pd
@@ -1177,29 +1177,6 @@ def explicit_indexing_adapter(
11771177
raise TypeError(f"unexpected key type: {key}")
11781178

11791179

1180-
class CompatIndexedTuple(tuple):
1181-
"""
1182-
A tuple subclass used to transition existing backend implementations towards the use of raw tuples
1183-
for indexing by carrying additional metadata about the type of indexing being
1184-
performed ('basic', 'vectorized', or 'outer'). This class serves as a bridge, allowing
1185-
backend arrays that currently expect this metadata to function correctly while
1186-
maintaining the outward behavior of a regular tuple.
1187-
1188-
This class is particularly useful during the phase where the backend implementations are
1189-
not yet capable of directly accepting raw tuples without additional context about
1190-
the indexing type. It ensures that these backends can still correctly interpret and
1191-
process indexing operations by providing them with the necessary contextual information.
1192-
"""
1193-
1194-
def __new__(cls, iterable, indexer_type: Literal["basic", "vectorized", "outer"]):
1195-
obj = super().__new__(cls, iterable)
1196-
obj.indexer_type = indexer_type # type: ignore[attr-defined]
1197-
return obj
1198-
1199-
def __repr__(self):
1200-
return f"CompatIndexedTuple({super().__repr__()}, indexer_type='{self.indexer_type}')"
1201-
1202-
12031180
def apply_indexer(indexable, indexer: ExplicitIndexer) -> Any:
12041181
"""Apply an indexer to an indexable object."""
12051182
if isinstance(indexer, VectorizedIndexer):
@@ -1226,19 +1203,8 @@ def set_with_indexer(indexable, indexer: ExplicitIndexer, value: Any) -> None:
12261203

12271204

12281205
def decompose_indexer(
1229-
indexer: ExplicitIndexer | CompatIndexedTuple,
1230-
shape: _Shape,
1231-
indexing_support: IndexingSupport,
1206+
indexer: ExplicitIndexer, shape: _Shape, indexing_support: IndexingSupport
12321207
) -> tuple[ExplicitIndexer, ExplicitIndexer]:
1233-
if isinstance(indexer, CompatIndexedTuple):
1234-
# recreate the indexer object from the tuple and the type of indexing.
1235-
# This is necessary to ensure that the backend array can correctly interpret the indexing operation.
1236-
if indexer.indexer_type == "vectorized": # type: ignore[attr-defined]
1237-
indexer = VectorizedIndexer(indexer)
1238-
elif indexer.indexer_type == "outer": # type: ignore[attr-defined]
1239-
indexer = OuterIndexer(indexer)
1240-
else:
1241-
indexer = BasicIndexer(indexer)
12421208
if isinstance(indexer, VectorizedIndexer):
12431209
return _decompose_vectorized_indexer(indexer, shape, indexing_support)
12441210
if isinstance(indexer, BasicIndexer | OuterIndexer):

0 commit comments

Comments
 (0)