Skip to content

Commit

Permalink
possible fix for failing groupby test
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNicholas committed Mar 28, 2024
1 parent 21afbb1 commit 6e9ead6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions xarray/core/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,11 @@ def get_indexes(name):
for name, result_var in result_vars.items()
if name in coord_names
}
result_data_vars = {
name: result_var
for name, result_var in result_vars.items()
if name not in coord_names
}

if index is not None:
if dim_var is not None:
Expand All @@ -668,16 +673,14 @@ def get_indexes(name):
coord_vars[dim] = index_vars[dim]
result_indexes[dim] = index
unlabeled_dims = unlabeled_dims - set([dim])
else:
if dim in result_data_vars:
coord_vars[dim] = result_data_vars[dim]
result_data_vars.pop(dim)

# TODO: add indexes at Dataset creation (when it is supported)
coords = Coordinates(coord_vars, indexes=result_indexes)

result_data_vars = {
name: result_var
for name, result_var in result_vars.items()
if name not in coord_names
}

result = type(datasets[0])(result_data_vars, coords=coords, attrs=result_attrs)
result.encoding = result_encoding

Expand Down

0 comments on commit 6e9ead6

Please sign in to comment.