update pip install .copy manifest for developments
This commit is contained in:
+22
-2
@@ -57,13 +57,33 @@ def test_pyproject_bundle_manifest(packaging_utils):
|
||||
assert all("/" in path and "*" not in path for path in config_files)
|
||||
assert any(path.endswith(".json") for path in config_files)
|
||||
|
||||
sensor_dirs = [dest for dest in data_files if dest.startswith("orisys/sensors/")]
|
||||
sensor_dirs = [dest for dest in data_files if dest.startswith("orisys/sensors")]
|
||||
assert sensor_dirs
|
||||
assert any("finger/assets" in dest for dest in sensor_dirs)
|
||||
all_sensor_files = [path for files in (data_files[d] for d in sensor_dirs) for path in files]
|
||||
assert any(path.endswith("force_calibration.json") for path in all_sensor_files)
|
||||
assert any("finger" in path and path.endswith(".json") for path in all_sensor_files)
|
||||
# Finger mesh/viz assets (flat or nested assets/finger/ checkout).
|
||||
assert any("finger/assets" in dest or any("finger/assets" in p for p in data_files[dest]) for dest in sensor_dirs)
|
||||
assert all("*" not in path for files in data_files.values() for path in files)
|
||||
assert "examples" not in data_files
|
||||
|
||||
|
||||
def test_stage_dev_bundle_into_writes_sensors_under_package(tmp_path):
|
||||
import sys
|
||||
|
||||
build_dir = REPO_ROOT / "build"
|
||||
if str(build_dir) not in sys.path:
|
||||
sys.path.insert(0, str(build_dir))
|
||||
from common.pyproject_utils import stage_dev_bundle_into
|
||||
|
||||
pkg = tmp_path / "orisys"
|
||||
packaged = stage_dev_bundle_into(REPO_ROOT, pkg)
|
||||
assert any(p.replace("\\", "/").endswith("sensors/box/force_calibration.json") for p in packaged)
|
||||
assert (pkg / "sensors" / "box" / "force_calibration.json").is_file()
|
||||
assert (pkg / "configs").is_dir()
|
||||
assert any((pkg / "configs").glob("*.json"))
|
||||
|
||||
|
||||
def test_bundle_explicit_files():
|
||||
import sys
|
||||
|
||||
|
||||
@@ -129,7 +129,16 @@ def test_configure_lowpass_filters_read_info_and_keeps_raw():
|
||||
sensor.info.FSHEARX,
|
||||
sensor.info.FSHEARY,
|
||||
)
|
||||
assert (fn, fx, fy) == pytest.approx((1000.0, -200.0, 50.0))
|
||||
fn_raw, fx_raw, fy_raw = sensor.read_info(
|
||||
sensor.info.FNORMAL_RAW,
|
||||
sensor.info.FSHEARX_RAW,
|
||||
sensor.info.FSHEARY_RAW,
|
||||
)
|
||||
assert (fn_raw, fx_raw, fy_raw) == pytest.approx((1000.0, -200.0, 50.0))
|
||||
assert fn == pytest.approx(calibrate_normal_force(1000.0, sensor_name="box"))
|
||||
assert (fx, fy) == pytest.approx(
|
||||
calibrate_shear_components(-200.0, 50.0, sensor_name="box")
|
||||
)
|
||||
|
||||
sensor.configure(lowpass_cutoff_hz=5.0, lowpass_sample_rate_hz=30.0)
|
||||
noisy = [(1000.0 + (200.0 if i % 2 else -200.0), -200.0, 50.0) for i in range(40)]
|
||||
@@ -166,7 +175,10 @@ def test_configure_lowpass_disabled_or_zero_cutoff_returns_raw():
|
||||
sensor.info.FSHEARX,
|
||||
sensor.info.FSHEARY,
|
||||
)
|
||||
assert (fn, fx, fy) == pytest.approx((111.0, 222.0, 333.0))
|
||||
assert fn == pytest.approx(calibrate_normal_force(111.0, sensor_name="box"))
|
||||
assert (fx, fy) == pytest.approx(
|
||||
calibrate_shear_components(222.0, 333.0, sensor_name="box")
|
||||
)
|
||||
|
||||
sensor.configure(lowpass_cutoff_hz=5.0, lowpass_enabled=False)
|
||||
sensor._force_raw = (7.0, 8.0, 9.0)
|
||||
@@ -177,12 +189,59 @@ def test_configure_lowpass_disabled_or_zero_cutoff_returns_raw():
|
||||
sensor.info.FSHEARY,
|
||||
)
|
||||
fn_raw = sensor.read_info(sensor.info.FNORMAL_RAW)[0]
|
||||
assert (fn, fx, fy) == pytest.approx((7.0, 8.0, 9.0))
|
||||
assert fn == pytest.approx(calibrate_normal_force(7.0, sensor_name="box"))
|
||||
assert (fx, fy) == pytest.approx(
|
||||
calibrate_shear_components(8.0, 9.0, sensor_name="box")
|
||||
)
|
||||
assert fn_raw == pytest.approx(7.0)
|
||||
finally:
|
||||
sensor.disconnect()
|
||||
|
||||
|
||||
def test_box_read_info_applies_force_calibration_json():
|
||||
sensor = _external_sensor()
|
||||
try:
|
||||
assert sensor._force_cal_sensor_name == "box"
|
||||
sensor._force_raw = (10000.0, 36000.0, -36000.0)
|
||||
sensor._apply_force_filter()
|
||||
fn, fx, fy = sensor.read_info(
|
||||
sensor.info.FNORMAL,
|
||||
sensor.info.FSHEARX,
|
||||
sensor.info.FSHEARY,
|
||||
)
|
||||
fn_raw, fx_raw, fy_raw = sensor.read_info(
|
||||
sensor.info.FNORMAL_RAW,
|
||||
sensor.info.FSHEARX_RAW,
|
||||
sensor.info.FSHEARY_RAW,
|
||||
)
|
||||
assert (fn_raw, fx_raw, fy_raw) == pytest.approx((10000.0, 36000.0, -36000.0))
|
||||
assert fn == pytest.approx(0.377)
|
||||
assert fx == pytest.approx(1.19)
|
||||
assert fy == pytest.approx(-1.19)
|
||||
finally:
|
||||
sensor.disconnect()
|
||||
|
||||
|
||||
def test_read_info_force_stays_raw_without_calibration_json(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"orisys.sensor.configs.load_force_calibration",
|
||||
lambda _name: None,
|
||||
)
|
||||
sensor = Sensor("external", config_name="box", verbose=False, backend="cpu")
|
||||
try:
|
||||
assert sensor._force_cal_sensor_name is None
|
||||
sensor._force_raw = (111.0, -22.0, 33.0)
|
||||
sensor._apply_force_filter()
|
||||
fn, fx, fy = sensor.read_info(
|
||||
sensor.info.FNORMAL,
|
||||
sensor.info.FSHEARX,
|
||||
sensor.info.FSHEARY,
|
||||
)
|
||||
assert (fn, fx, fy) == pytest.approx((111.0, -22.0, 33.0))
|
||||
finally:
|
||||
sensor.disconnect()
|
||||
|
||||
|
||||
def test_configure_hhd_downsample_invalidates_solver_cache():
|
||||
sensor = _external_sensor()
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user