Skip to content

limit-up-board v0.18.1 — 兼容新框架严格 canonical_json(指纹 NaN/Inf/set 兜底)#2

Merged
ty19880929 merged 1 commit into
mainfrom
limit-up-board-v0.18.1
May 27, 2026
Merged

limit-up-board v0.18.1 — 兼容新框架严格 canonical_json(指纹 NaN/Inf/set 兜底)#2
ty19880929 merged 1 commit into
mainfrom
limit-up-board-v0.18.1

Conversation

@ty19880929

Copy link
Copy Markdown
Owner

背景

新框架(deeptrade-quant ≥ 0.5,本地验证于 0.15.0)把 deeptrade.core.fingerprint.canonical_json 的契约改严:对 NaN/InfValueError、对 set/frozensetTypeError(不再自动归一)。插件 fingerprint.py 在框架可用时直接复用框架原语,导致:

  • 运行时隐患build_input_fingerprint 会哈希 Tushare 派生的候选浮点字段(新股常见 NaN),新框架下 hash_json 直接抛错 → run 指纹计算崩溃(v0.18.0 在新框架上的真实 bug)。
  • CI 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-quant 0.4.2 → 0.15.0;全套 678 passedtools/check_registry.py OK。对新旧框架均兼容。

🤖 Generated with Claude Code

新框架 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>
@ty19880929 ty19880929 merged commit 261e42a into main May 27, 2026
3 checks passed
@ty19880929 ty19880929 deleted the limit-up-board-v0.18.1 branch May 27, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant