Skip to content

Fix generator exhaustion in combine_by_coords#11265

Open
SurfyPenguin wants to merge 2 commits intopydata:mainfrom
SurfyPenguin:fix/combine-by-coords-returns-empty-dataset
Open

Fix generator exhaustion in combine_by_coords#11265
SurfyPenguin wants to merge 2 commits intopydata:mainfrom
SurfyPenguin:fix/combine-by-coords-returns-empty-dataset

Conversation

@SurfyPenguin
Copy link
Copy Markdown
Contributor

This pull request applies the suggested fix tracked in #10114 and fixes combine_by_coords returning an empty Dataset when a generator is passed as data_objects.

`combine_by_coords` accepts `Iterable[Dataset | DataArray]`.

When a generator is passed, it is exhausted by the `DataTree` isinstance
check before `objs_are_unnamed_dataarrays` is assigned, causing subsequent
iterations to yield nothing and returning an empty Dataset.

Fix by materializing `data_objects` into a list.
@welcome
Copy link
Copy Markdown

welcome bot commented Mar 26, 2026

Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient.
If you have questions, some answers may be found in our contributing guidelines.

@headtr1ck headtr1ck added bug plan to merge Final call for comments labels Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug plan to merge Final call for comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Iterable[Dataset | DataArray] issue with xarray.core.combine.combine_by_coords

2 participants