Skip to content

Commit

Permalink
store safe_cast_to_index call to avoid double call
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer Hill committed Mar 31, 2020
1 parent fdeffd9 commit 4407f40
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions xarray/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,12 @@ def __init__(
group = group.dropna(group_dim)

# look through group to find the unique values
group_as_index = safe_cast_to_index(group)
sort = bins is None and (
not isinstance(safe_cast_to_index(group), pd.MultiIndex)
not isinstance(group_as_index, pd.MultiIndex)
)
unique_values, group_indices = unique_value_groups(
safe_cast_to_index(group), sort=sort
group_as_index, sort=sort
)
unique_coord = IndexVariable(group.name, unique_values)

Expand Down

0 comments on commit 4407f40

Please sign in to comment.