Skip to content

Commit 84ef547

Browse files
committed
more cleanup
1 parent 49fbedc commit 84ef547

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
@@ -2993,19 +2993,20 @@ def isel(
29932993
# underlying array's shape and ndim since the dims are already
29942994
# cached by the Variable
29952995
var_dims = var.dims
2996-
# preserve variable order
2997-
if name in index_variables:
2998-
var = index_variables[name]
29992996
# Fastpath, skip all this metadata analysis for variables
30002997
# with no dimensions
3001-
elif var_dims and (var_indexer_keys := all_keys.intersection(var_dims)):
3002-
var_indexers = {k: indexers[k] for k in var_indexer_keys}
3003-
var = var.isel(var_indexers)
3004-
if drop and var.ndim == 0 and name in coord_names:
3005-
coord_names.remove(name)
3006-
continue
2998+
if var_dims:
2999+
# preserve variable order
3000+
if name in index_variables:
3001+
var = index_variables[name]
3002+
elif var_indexer_keys := all_keys.intersection(var_dims):
3003+
var_indexers = {k: indexers[k] for k in var_indexer_keys}
3004+
var = var.isel(var_indexers)
3005+
if drop and var.ndim == 0 and name in coord_names:
3006+
coord_names.remove(name)
3007+
continue
30073008
variables[name] = var
3008-
dims.update(zip(var.dims, var.shape))
3009+
dims.update(zip(var_dims, var.shape))
30093010

30103011
return self._construct_direct(
30113012
variables=variables,

0 commit comments

Comments
 (0)