fix(python): constructable GaussianHmmParamsPy + dict-like backtest metrics (nhkk)#12
Merged
Conversation
…etrics (nhkk) Two record-port gaps from the uniffi->PyO3 migration, surfaced by relocating the previously-CI-invisible tests: 1. GaussianHmmParamsPy is an INPUT params record that Python constructs (qw.GaussianHmmParamsPy(n_states=..., delta=..., ...)), but the ported #[pyclass(get_all)] had no #[new], so construction raised "No constructor defined". Add a #[new] (lambdas defaults to empty = Gaussian mode). Audited all 49 records: this is the only one Python constructs; the rest are read-only outputs. 2. PerformanceMetrics / BacktestStats define __getitem__(str) + keys() but no __contains__, so `"sharpe_ratio" in metrics` fell back to integer-index iteration (getattr(self, 0)) -> "TypeError: attribute name must be string, not 'int'". Add __contains__ and __iter__ so they behave dict-like. Fixes test_hmm_forecast (2), test_ml_feature_backtest_parity, test_strategy_backtest. Full suite 6 -> 2 failures (remaining: pandas-only benchmark test + a stale LazyFrame.ta test_parity, both unrelated). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Two
uniffi → PyO3record-port gaps, surfaced when the previously-CI-invisible tests were relocated totests/python/(both confirmed pre-existing onmain, not regressions from the FFI work):GaussianHmmParamsPyhad no#[new]. It's an input params record Python constructs (qw.GaussianHmmParamsPy(n_states=…, delta=…, …)), but the ported#[pyclass(get_all)]wasn't constructable → "No constructor defined". Added#[new](lambdasdefaults to empty = Gaussian mode). Audited all 49 records — this is the only one Python constructs; the rest are read-only outputs.PerformanceMetrics/BacktestStatsbroke theinoperator. They had__getitem__(str)+keys()but no__contains__, so"sharpe_ratio" in metricsfell back to integer-index iteration →TypeError: attribute name must be string, not 'int'. Added__contains__+__iter__(now properly dict-like).Result: fixes
test_hmm_forecast(2),test_ml_feature_backtest_parity,test_strategy_backtest. Full suite 6 → 2 failures; the remaining two are unrelated — apandas-only benchmark test and a staleLazyFrame.tatest_parity.🤖 Generated with Claude Code