Skip to content

Commit 1f072d6

Browse files
dcherianhmaarrfk
authored andcommitted
more cleanup
1 parent 372dd9e commit 1f072d6

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

xarray/core/dataset.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2995,19 +2995,20 @@ def isel(
29952995
# underlying array's shape and ndim since the dims are already
29962996
# cached by the Variable
29972997
var_dims = var.dims
2998-
# preserve variable order
2999-
if name in index_variables:
3000-
var = index_variables[name]
30012998
# Fastpath, skip all this metadata analysis for variables
30022999
# with no dimensions
3003-
elif var_dims and (var_indexer_keys := all_keys.intersection(var_dims)):
3004-
var_indexers = {k: indexers[k] for k in var_indexer_keys}
3005-
var = var.isel(var_indexers)
3006-
if drop and var.ndim == 0 and name in coord_names:
3007-
coord_names.remove(name)
3008-
continue
3000+
if var_dims:
3001+
# preserve variable order
3002+
if name in index_variables:
3003+
var = index_variables[name]
3004+
elif var_indexer_keys := all_keys.intersection(var_dims):
3005+
var_indexers = {k: indexers[k] for k in var_indexer_keys}
3006+
var = var.isel(var_indexers)
3007+
if drop and var.ndim == 0 and name in coord_names:
3008+
coord_names.remove(name)
3009+
continue
30093010
variables[name] = var
3010-
dims.update(zip(var.dims, var.shape))
3011+
dims.update(zip(var_dims, var.shape))
30113012

30123013
return self._construct_direct(
30133014
variables=variables,

0 commit comments

Comments
 (0)