Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Dec 13, 2024
1 parent 0c2f03d commit 2cd2674
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4185,7 +4185,7 @@ def _validate_interp_indexer(x, new_x):
}

variables: dict[Hashable, Variable] = {}
reindex: bool = False
reindex_vars: list[Hashable] = []
for name, var in obj._variables.items():
if name in indexers:
continue
Expand All @@ -4207,20 +4207,20 @@ def _validate_interp_indexer(x, new_x):
# booleans and objects and retains the dtype but inside
# this loop there might be some duplicate code that slows it
# down, therefore collect these signals and run it later:
reindex = True
reindex_vars.append(name)
elif all(d not in indexers for d in var.dims):
# For anything else we can only keep variables if they
# are not dependent on any coords that are being
# interpolated along:
variables[name] = var

if reindex and (
if reindex_vars and (
reindex_indexers := {
k: v for k, (_, v) in validated_indexers.items() if v.dims == (k,)
}
):
reindexed = alignment.reindex(
obj,
obj[reindex_vars],
indexers=reindex_indexers,
method=method_non_numeric,
exclude_vars=variables.keys(),
Expand Down

0 comments on commit 2cd2674

Please sign in to comment.