Add simultaneous member and init resampling to HindcastEnsemble.bootstrap with xbootstrap integration #876
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the ability to resample both "member" and "init" dimensions simultaneously in
HindcastEnsemble.bootstrap(), addressing the feature request in the original issue. The implementation now integrates with thexbootstraplibrary for efficient nested block bootstrap resampling.Problem
Previously,
HindcastEnsemble.bootstrap()only supported resampling along a single dimension at a time:Users requested the ability to resample both dimensions simultaneously for more comprehensive bootstrap analysis.
Solution
The
resample_dimparameter now accepts both single strings and lists of strings, enabling simultaneous multi-dimensional resampling:Implementation Details
Enhanced Type Support: Updated method signatures to accept
Union[str, List[str]]forresample_dimparameterxbootstrap Integration: Added optional integration with the
xbootstraplibrary for efficient nested circular block bootstrap resamplingxb.block_bootstrap()for multi-dimensional resampling when availableSmart Routing Logic: Modified bootstrap logic to detect multi-dimensional resampling and automatically choose the most efficient method:
Backward Compatibility: All existing single-dimension calls continue to work unchanged with no API modifications required
Comprehensive Documentation: Updated docstrings with examples and clear descriptions of the new functionality, including xbootstrap integration notes
Files Changed
src/climpred/bootstrap.py: Added xbootstrap integration,_resample_multiple_dims_xbootstrap()function,resample_skill_xbootstrap()method, and updated existing functionssrc/climpred/classes.py: Updated method signatures, bootstrap logic with xbootstrap routing, and documentationsrc/climpred/tests/test_bootstrap.py: Added comprehensive tests for multi-dimensional resampling including xbootstrap-specific testsTesting
Added test coverage for:
Key Benefits
This enhancement provides users with more flexible and efficient bootstrap analysis capabilities while maintaining full backward compatibility with existing code.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.