Skip to content

Commit e52477f

Browse files
committed
Update & fix DLCLive compatibility tests
Relax and correct DLCLive compatibility checks: only consider keyword/positional params when inspecting __init__, drop the assertion that __init__ must accept **kwargs, and only require 'frame' for init_inference/get_pose (frame_time is passed as a kwarg to processors). Also update FakeDLCLive.get_pose to return an array of shape (2, 3) to match the expected pose output shape.
1 parent 882717b commit e52477f

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

tests/compat/test_dlclive_package_compat.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,14 @@ def test_dlclive_constructor_accepts_gui_expected_kwargs():
5353
"single_animal",
5454
"device",
5555
}
56-
params, accepts_var_kw = _get_signature_params(DLCLive.__init__)
56+
params, _ = _get_signature_params(DLCLive.__init__)
57+
params = {
58+
name
59+
for name, p in params.items()
60+
if p.kind in (inspect.Parameter.KEYWORD_ONLY, inspect.Parameter.POSITIONAL_OR_KEYWORD)
61+
}
5762
missing = {name for name in expected if name not in params}
5863
assert not missing, f"DLCLive.__init__ is missing expected kwargs called by GUI: {sorted(missing)}"
59-
assert accepts_var_kw, "DLCLive.__init__ should accept **kwargs" # captures current behavior
6064

6165

6266
@pytest.mark.dlclive_compat
@@ -70,13 +74,15 @@ def test_dlclive_methods_match_gui_usage():
7074

7175
assert hasattr(DLCLive, "init_inference"), "DLCLive must provide init_inference(frame)"
7276
assert hasattr(DLCLive, "get_pose"), "DLCLive must provide get_pose(frame, frame_time=...)"
77+
# NOTE: frame_time is passed as a kwarg, so we only check for "frame" as a required param.
78+
# This is used by DLCLive Processor classes, rather than the DLCLive class itself.
7379

7480
init_params, _ = _get_signature_params(DLCLive.init_inference)
7581
init_missing = {name for name in {"frame"} if name not in init_params}
7682
assert not init_missing, f"DLCLive.init_inference signature mismatch, missing: {sorted(init_missing)}"
7783

7884
get_pose_params, _ = _get_signature_params(DLCLive.get_pose)
79-
get_pose_missing = {name for name in {"frame", "frame_time"} if name not in get_pose_params}
85+
get_pose_missing = {name for name in {"frame"} if name not in get_pose_params}
8086
assert not get_pose_missing, f"DLCLive.get_pose signature mismatch, missing: {sorted(get_pose_missing)}"
8187

8288

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def init_inference(self, frame):
168168

169169
def get_pose(self, frame, frame_time=None):
170170
self.pose_calls += 1
171-
return np.ones((2, 2), dtype=float)
171+
return np.ones((2, 3), dtype=float)
172172

173173

174174
@pytest.fixture

0 commit comments

Comments
 (0)