Skip to content

Allow custom indexes to create new variables #10503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dhruvak001
Copy link
Contributor

@dhruvak001 dhruvak001 commented Jul 4, 2025

Previously, set_xindex silently ignored any extra variables returned by custom indexes' create_variables method, only adding variables that matched the original coordinate names. This prevented custom indexes from providing additional computed variables, limiting their usefulness for advanced indexing scenarios like weather forecasting where derived coordinates are needed.

This change modifies set_xindex in dataset.py to add all variables returned by create_variables(), not just those matching coordinate names. The implementation simply iterates through all returned variables instead of filtering by coordinate names.

The fix enables custom indexes to provide computed variables while maintaining full backward compatibility. Existing code continues to work unchanged, but custom indexes can now return additional variables that will be properly added to the dataset, resolving the silent ignoring behavior that was confusing to users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow custom indexes to create new variables
1 participant