86996694b4
移除自动显示基线,使逐轴阈值统一作用于曲线、读数与记录输出,标定拟合继续使用原始采样。 共享层全量测试和相关 Studio 测试通过。
36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
"""Absolute force thresholds preserve unavailable axes and original values."""
|
|
|
|
import numpy as np
|
|
|
|
from orisys_app_shared.force.presentation import ForcePresentation, threshold_force
|
|
|
|
|
|
def test_threshold_is_absolute_and_independent_per_axis():
|
|
policy = ForcePresentation(min_deadband_raw=50.0, min_deadband_n=0.5)
|
|
displayed = policy.accept((49.0, -50.0, 51.0), unit="raw")
|
|
assert displayed.values == (0.0, 0.0, 51.0)
|
|
assert displayed.suppressed == (True, True, False)
|
|
newtons = policy.accept((0.4, -0.6, float("nan")), unit="N")
|
|
assert newtons.values[:2] == (0.0, -0.6)
|
|
assert np.isnan(newtons.values[2])
|
|
|
|
|
|
def test_scalar_and_array_paths_agree_without_mutating_input():
|
|
source = np.array([[49.0, -51.0, np.nan]])
|
|
policy = ForcePresentation(min_deadband_raw=50.0)
|
|
output, mask = policy.present(source, unit="raw")
|
|
assert output[0, :2].tolist() == [0.0, -51.0]
|
|
assert mask.tolist() == [[True, False, False]]
|
|
assert source[0, 0] == 49.0
|
|
assert threshold_force(49.0, 50.0) == output[0, 0]
|
|
|
|
|
|
def test_precision_is_per_unit_and_does_not_change_threshold():
|
|
policy = ForcePresentation(min_deadband_raw=50.0, min_deadband_n=0.5)
|
|
assert policy.format_force(50.6, "raw") == "51"
|
|
assert policy.format_force(0.506, "N") == "0.51"
|
|
assert policy.format_force(-0.004, "N") == "0.00"
|
|
assert policy.format_force(float("nan"), "raw") == "—"
|
|
policy.raw_decimals = 1
|
|
assert policy.format_force(50.6, "raw") == "50.6"
|