Resolve duplicate "datetime" level across remaining qlib call sites#2217
Open
genisis0x wants to merge 1 commit into
Open
Resolve duplicate "datetime" level across remaining qlib call sites#2217genisis0x wants to merge 1 commit into
genisis0x wants to merge 1 commit into
Conversation
Follow-up hardening on top of the microsoft#1909 PortAnaRecord fix. Several other sites still call `index.get_level_values("datetime")` and would crash with `ValueError: 'datetime' occurs multiple times` on the same MultiIndex shape: - qlib/utils/__init__.py::split_pred - qlib/contrib/evaluate.py::backtest_analysis (long/short returns loop) - qlib/workflow/online/update.py::PredUpdater.__init__ and _replace_range - qlib/workflow/online/manager.py::OnlineManager.prepare_signals / routine - qlib/model/ens/ensemble.py::RollingEnsemble.__call__ - qlib/data/dataset/__init__.py::DatasetH.setup_data All switch to positional level resolution via `index.names.index("datetime")`. Added a regression test in `tests/misc/test_datetime_level_lookup_helpers.py` covering split_pred. Refs microsoft#1909
Author
|
@microsoft-github-policy-service agree |
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
Follow-up hardening on top of #2216 (which fixed
PortAnaRecordfor #1909).Auditing the codebase for the same name-based
index.get_level_values(\"datetime\")pattern surfaced several additional sites that would crash with the sameValueError: 'datetime' occurs multiple timeson the same MultiIndex shape:qlib/utils/__init__.py—split_predqlib/contrib/evaluate.py— long/short returns loop inbacktest_analysisqlib/workflow/online/update.py—PredUpdater.__init__and_replace_rangeqlib/workflow/online/manager.py—OnlineManager.prepare_signalsandroutineqlib/model/ens/ensemble.py—RollingEnsemble.__call__qlib/data/dataset/__init__.py—DatasetH.setup_dataAll call sites switch to positional level resolution:
This matches the resolution used in #2216.
Test plan
tests/misc/test_datetime_level_lookup_helpers.pybuilds the same duplicate-datetimeMultiIndex used in the Fix PortAnaRecord crash on duplicate "datetime" level (#1909) #2216 regression test and exercisessplit_pred, asserting:split_predruns and returns a complete partition (left + right = input)datetimeindexes (positional lookup of the firstdatetimelevel is equivalent when the name is unique)Refs #1909