fix(sampler): validate level param rejects invalid values
Add ValueError guard at the top of sample_material_v2 for level not in
{1, 2, 3}, preventing silent fallthrough to L1 sampling. Add unit test
for the new validation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -525,8 +525,12 @@ def sample_material_v2(
|
||||
MaterialContext 实例。
|
||||
|
||||
异常:
|
||||
ValueError: level 不在 {1, 2, 3} 中。
|
||||
RuntimeError: 耗尽 max_attempts 次尝试仍无法满足约束。
|
||||
"""
|
||||
if level not in (1, 2, 3):
|
||||
msg = f"level 必须为 1、2 或 3,收到: {level}"
|
||||
raise ValueError(msg)
|
||||
|
||||
for attempt in range(max_attempts):
|
||||
# Phase 1: 按层级采样候选节点
|
||||
|
||||
Reference in New Issue
Block a user