Skip to content

Commit

Permalink
effectively remove fastpath
Browse files Browse the repository at this point in the history
  • Loading branch information
hmaarrfk committed Jun 29, 2024
1 parent 337532c commit 0f1a5a2
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions xarray/core/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,19 +580,10 @@ def __init__(
array: Any,
dim: Hashable,
coord_dtype: Any = None,
*,
fastpath: bool = False,
):
if fastpath:
index = array
else:
index = safe_cast_to_index(array)
index = safe_cast_to_index(array).copy()

if index.name is None:
# make a shallow copy: cheap and because the index name may be updated
# here or in other constructors (cannot use pd.Index.rename as this
# constructor is also called from PandasMultiIndex)
index = index.copy()
index.name = dim

self.index = index
Expand All @@ -607,7 +598,7 @@ def _replace(self, index, dim=None, coord_dtype=None):
dim = self.dim
if coord_dtype is None:
coord_dtype = self.coord_dtype
return type(self)(index, dim, coord_dtype, fastpath=True)
return type(self)(index, dim, coord_dtype)

@classmethod
def from_variables(
Expand Down Expand Up @@ -653,11 +644,6 @@ def from_variables(

obj = cls(data, dim, coord_dtype=var.dtype)
assert not isinstance(obj.index, pd.MultiIndex)
# Rename safely
# make a shallow copy: cheap and because the index name may be updated
# here or in other constructors (cannot use pd.Index.rename as this
# constructor is also called from PandasMultiIndex)
obj.index = obj.index.copy()
obj.index.name = name

return obj
Expand Down

0 comments on commit 0f1a5a2

Please sign in to comment.