Repository navigation
fix(base): ignore unused alignment levels - #914
Open
JohnDReynolds wants to merge 1 commit into
Open
JohnDReynolds wants to merge 1 commit into
JohnDReynolds wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Currently, filtering a MultiIndex can leave unused labels in its levels. Aligning prices for assets A and B to a filtered parameter grid can then raise
ValueErrorsolely because an unused C remains in the grid's metadata.This PR fixes that by checking observed level labels and preserving normal
ValueErrorrejection for empty sources. Existing complete-key and duplicate-source checks remain in place.Benefit and scope: Allows filtered parameter grids to align through the index helper,
.vbt.align_toand broadcasting with a small correction to the existing alignment helper.Validation
Regression evidence
A grid filtered from assets A, B and C to A and B now aligns to the expected price columns even though C remains in its metadata. Regressions check the complete values and labels through
.vbt.align_toand broadcasting on both rows and columns. Coverage also includes reordered and repeated keys, categorical labels combined with missing keys, unchanged inputs, and rejection of absent source keys. Empty sources reject unmatchable target keys withValueError, while valid missing-key and empty-target cases remain covered. All 26 focused cases and the complete base test module (380 tests) pass.Checks
pytest tests/test_base.py: 380 passed, with one existing column-orientation UserWarning.pytest tests/: 1,938 passed and 2 skipped on the final amended commit.AI use