Skip to content

Commit e8e6fbc

Browse files
committed
Small cleanup
1 parent adf6ad0 commit e8e6fbc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

xarray/core/computation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,8 @@ def apply_dataarray_vfunc(
260260
args, join=join, copy=False, exclude=exclude_dims, raise_on_invalid=False
261261
)
262262

263-
first_obj = _first_of_type(args, DataArray)
264-
265263
if keep_attrs:
264+
first_obj = _first_of_type(args, DataArray)
266265
name = first_obj.name
267266
else:
268267
name = result_name(args)
@@ -408,15 +407,16 @@ def apply_dataset_vfunc(
408407
"""
409408
from .dataset import Dataset
410409

411-
first_obj = _first_of_type(args, Dataset)
412-
413410
if dataset_join not in _JOINS_WITHOUT_FILL_VALUES and fill_value is _NO_FILL_VALUE:
414411
raise TypeError(
415412
"to apply an operation to datasets with different "
416413
"data variables with apply_ufunc, you must supply the "
417414
"dataset_fill_value argument."
418415
)
419416

417+
if keep_attrs:
418+
first_obj = _first_of_type(args, Dataset)
419+
420420
if len(args) > 1:
421421
args = deep_align(
422422
args, join=join, copy=False, exclude=exclude_dims, raise_on_invalid=False

0 commit comments

Comments
 (0)