limit-up-board v0.18.1 — 兼容新框架严格 canonical_json(指纹 NaN/Inf/set 兜底)#2
Merged
Conversation
新框架 deeptrade.core.fingerprint.canonical_json 改严:对 NaN/Inf 抛 ValueError、 对 set/frozenset 抛 TypeError(不再自动归一)。插件 fingerprint.py 在框架可用时 直接复用框架原语,导致 build_input_fingerprint 哈希 Tushare 派生候选浮点(新股 常见 NaN)时 hash_json 直接抛错 → run 指纹计算崩溃;CI test_fingerprint 两例失败。 Fixed: - _normalize 提为模块级并在框架路径生效:插件 canonical_json 现在「先归一 (NaN/Inf→None、set→排序 list、dataclass→asdict、Mapping 键→str) 再委托框架」, 保留本模块 NaN-safe 契约,同时让框架的 datetime/Decimal/numpy/BaseModel 富类型 处理 + 版本化契约继续作为单一事实源。对 0.4.2 与 0.15.0 均兼容,全套 678 通过。 - 新增回归测试 test_input_fingerprint_survives_nan_and_inf_in_candidates。 Co-Authored-By: Claude Opus 4.7 (1M context) <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.
背景
新框架(
deeptrade-quant≥ 0.5,本地验证于 0.15.0)把deeptrade.core.fingerprint.canonical_json的契约改严:对NaN/Inf抛ValueError、对set/frozenset抛TypeError(不再自动归一)。插件fingerprint.py在框架可用时直接复用框架原语,导致:build_input_fingerprint会哈希 Tushare 派生的候选浮点字段(新股常见 NaN),新框架下hash_json直接抛错 → run 指纹计算崩溃(v0.18.0 在新框架上的真实 bug)。test_fingerprint.py两个断言旧"自动归一"行为的用例失败(上一轮发版后 main 一直红)。修复
fingerprint._normalize提为模块级、并在框架路径生效:插件canonical_json现在「先归一(NaN/Inf→None、set→排序 list、dataclass→asdict、Mapping 键→str)再委托框架」,既保留本模块文档化的 NaN-safe 契约,又让框架的 datetime/Decimal/numpy/BaseModel 富类型处理 + 版本化契约继续作为单一事实源。test_input_fingerprint_survives_nan_and_inf_in_candidates(直接走build_input_fingerprint的 NaN/Inf 候选路径)。验证
deeptrade-quant0.4.2 → 0.15.0;全套 678 passed;tools/check_registry.pyOK。对新旧框架均兼容。🤖 Generated with Claude Code