mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-24 18:26:11 +00:00
test(visualization): fixing visualization tests
This commit is contained in:
@@ -115,7 +115,7 @@ def log_rerun_data(
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
img_entity = rr.Image(arr).compress() if compress_images else rr.Image(arr)
|
img_entity = rr.Image(arr).compress() if compress_images else rr.Image(arr)
|
||||||
rr.log(key, entity=img_entity)
|
rr.log(key, entity=img_entity, static=True)
|
||||||
|
|
||||||
if action:
|
if action:
|
||||||
for k, v in action.items():
|
for k, v in action.items():
|
||||||
|
|||||||
@@ -43,6 +43,11 @@ def mock_rerun(monkeypatch):
|
|||||||
def __init__(self, arr):
|
def __init__(self, arr):
|
||||||
self.arr = arr
|
self.arr = arr
|
||||||
|
|
||||||
|
class DummyDepthImage:
|
||||||
|
def __init__(self, arr, colormap=None):
|
||||||
|
self.arr = arr
|
||||||
|
self.colormap = colormap
|
||||||
|
|
||||||
def dummy_log(key, obj=None, **kwargs):
|
def dummy_log(key, obj=None, **kwargs):
|
||||||
# Accept either positional `obj` or keyword `entity` and record remaining kwargs.
|
# Accept either positional `obj` or keyword `entity` and record remaining kwargs.
|
||||||
if obj is None and "entity" in kwargs:
|
if obj is None and "entity" in kwargs:
|
||||||
@@ -55,6 +60,8 @@ def mock_rerun(monkeypatch):
|
|||||||
__spec__=SimpleNamespace(name="rerun", submodule_search_locations=None),
|
__spec__=SimpleNamespace(name="rerun", submodule_search_locations=None),
|
||||||
Scalars=DummyScalar,
|
Scalars=DummyScalar,
|
||||||
Image=DummyImage,
|
Image=DummyImage,
|
||||||
|
DepthImage=DummyDepthImage,
|
||||||
|
components=SimpleNamespace(Colormap=SimpleNamespace(Viridis="viridis")),
|
||||||
log=dummy_log,
|
log=dummy_log,
|
||||||
init=lambda *a, **k: None,
|
init=lambda *a, **k: None,
|
||||||
spawn=lambda *a, **k: None,
|
spawn=lambda *a, **k: None,
|
||||||
@@ -225,7 +232,7 @@ def test_log_rerun_data_kwargs_only(mock_rerun):
|
|||||||
assert temp.value == pytest.approx(10.0)
|
assert temp.value == pytest.approx(10.0)
|
||||||
|
|
||||||
img = _obj_for(calls, "observation.gray")
|
img = _obj_for(calls, "observation.gray")
|
||||||
assert type(img).__name__ == "DummyImage"
|
assert type(img).__name__ == "DummyDepthImage" # single-channel -> DepthImage
|
||||||
assert img.arr.shape == (8, 8, 1) # remains HWC
|
assert img.arr.shape == (8, 8, 1) # remains HWC
|
||||||
assert _kwargs_for(calls, "observation.gray").get("static", False) is True
|
assert _kwargs_for(calls, "observation.gray").get("static", False) is True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user