Files
orisys-app/apps/studio/tests/test_shared_depth_scale.py
ykcheungab 19ae1f4968 三维显示与二维共用深度色标,配置名改为 Finger
箭头阈值写入设置;去掉网格告警。三维色标改为立刻采用二维量程(不再 P5/P95 缓变)。选择器显示 Finger。已用 pane UI、shared-scale 与 catalog 单测验证。
2026-10-08 16:10:58 +08:00

61 lines
1.8 KiB
Python

"""2D and 3D depth colour bars name one interval."""
from __future__ import annotations
from types import SimpleNamespace
import numpy as np
from orisys_app_shared.scene3d.contracts import FieldDescriptor
from orisys_studio.scene3d.gl_backend import _field_scalar_range
def _field(quantity: str, values, *, signed: bool = False) -> SimpleNamespace:
arr = np.asarray(values, dtype=np.float32)
return SimpleNamespace(
descriptor=FieldDescriptor(quantity, "1", "approximate", signed),
scalar=arr,
valid=np.isfinite(arr),
)
def test_depth_automatic_scale_uses_the_shared_2d_span() -> None:
field = _field("depth_response", np.linspace(0.0, 9.0, 16).reshape(4, 4))
assert _field_scalar_range(
field,
previous=(0.0, 2.0),
shared_depth_scale=(0.0, 1.0),
) == (0.0, 1.0)
def test_flow_ignores_the_shared_depth_span() -> None:
field = _field("flow_magnitude", np.linspace(0.0, 9.0, 16).reshape(4, 4))
span = _field_scalar_range(
field,
previous=None,
shared_depth_scale=(0.0, 1.0),
)
assert span is not None
assert span != (0.0, 1.0)
assert span[1] > span[0]
def test_depth_without_a_shared_span_still_measures_the_field() -> None:
field = _field("depth_response", np.linspace(0.0, 9.0, 16).reshape(4, 4))
span = _field_scalar_range(
field,
previous=(0.0, 2.0),
shared_depth_scale=None,
)
assert span == (0.0, 9.0)
def test_a_degenerate_shared_span_falls_back_to_the_measurement() -> None:
field = _field("depth_response", np.linspace(0.0, 9.0, 16).reshape(4, 4))
span = _field_scalar_range(
field,
previous=None,
shared_depth_scale=(1.0, 1.0),
)
assert span is not None
assert span != (1.0, 1.0)