Add unit tests for PoseEstimation widgets - #16
Conversation
Co-authored-by: pauladkisson <34703136+pauladkisson@users.noreply.github.com>
Co-authored-by: pauladkisson <34703136+pauladkisson@users.noreply.github.com>
pauladkisson
left a comment
There was a problem hiding this comment.
Tests are showing the following error.
ImportError while loading conftest '/Users/runner/work/nwb-video-widgets/nwb-video-widgets/tests/conftest.py'.
tests/conftest.py:9: in
from tests.fixtures.synthetic_nwb import (
tests/fixtures/synthetic_nwb.py:6: in
from ndx_pose import PoseEstimation, PoseEstimationSeries
E ModuleNotFoundError: No module named 'ndx_pose'
Could you please add ndxpose to the test dependencies?
Co-authored-by: pauladkisson <34703136+pauladkisson@users.noreply.github.com>
Fixed in bc0d5e9. The import error occurred because |
|
@copilot could you update the change log? |
Co-authored-by: pauladkisson <34703136+pauladkisson@users.noreply.github.com>
|
I would like to hear what do you think I am thinking that: Maybe we should remove them, they will slow down refactoring. Also,even less sure about it, maybe we should use: Instead of fixtures here. Let me know what do you think. |
Personally, I feel like there are still useful unit tests even if they're just util functions. But happy to remove them if you insist.
Yeah, using the mock from NeuroConv is probably a good idea, just to avoid duplicate code. I'll implement here. |
|
@copilot, please replace the custom mock pose estimation code with a reference to this mock interface from NeuroConv: https://github.com/catalystneuro/neuroconv/blob/d5fddbde7d2bb398f48fedaf6daef5cb0ee1d0e6/src/neuroconv/tools/testing/mock_interfaces.py#L736 |
Co-authored-by: pauladkisson <34703136+pauladkisson@users.noreply.github.com>
Done in 4664342. The custom mock pose estimation code in
|
pauladkisson
left a comment
There was a problem hiding this comment.
You should be able to use the add_to_nwbfile method of the mock interface.
…PoseEstimation Co-authored-by: pauladkisson <34703136+pauladkisson@users.noreply.github.com>
Done in a148fa0. The fixtures now use |
Yes, let's remove them. |
Actually, upon looking at the implementation, using the mock interface from NeuroConv significantly complicates things:
So I think I would prefer to just keep them independent for now, and maybe we can streamline things down the road. |
Done! |
|
@h-mayorquin, this is ready for review |
|
Ok, thanks for trying, things to improve on the neuroconv mock for sure. |
Summary: Added Unit Tests for PoseEstimation Widgets
Successfully added comprehensive unit tests for the PoseEstimation widgets, following the existing testing conventions in the repository.
Changes Made
New Test File:
tests/test_local_pose_widget.py(19 tests)Updated Source Files:
src/nwb_video_widgets/_utils.py-discover_pose_estimation_camerasnow searches all processing modules (not just"pose_estimation"), making widgets compatible with NWB files where pose data is in"behavior"or any other modulesrc/nwb_video_widgets/local_pose_widget.py- Validation usesdiscover_pose_estimation_camerasresult instead of hardcoding the"pose_estimation"module; stores a_pose_containersdict instead of a module referencesrc/nwb_video_widgets/dandi_pose_widget.py- Same improvements aslocal_pose_widget.pyUpdated Test/Config Files:
tests/fixtures/synthetic_nwb.py- UsesMockPoseEstimationInterface.add_to_nwbfile()(NeuroConv's standard approach) for the first camera; additional cameras are added directly to the existing"behavior"module to avoid Device/Skeleton naming conflicts from repeatedadd_to_nwbfilecallstests/conftest.py- Added 3 new fixtures for pose estimation testingpyproject.toml- Addedndx-poseto main package dependencies;neuroconvadded to test dependenciesCHANGELOG.md- Added entry for v0.1.6 documenting test additionsTest Results
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.