-
Notifications
You must be signed in to change notification settings - Fork 54
Additional testing #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Additional testing #156
Conversation
Introduces .pre-commit-config.yaml to automate code formatting, linting, and basic checks using pre-commit hooks for improved code quality and consistency.
Upgraded GitHub Actions to use newer versions and improved test steps by separating model benchmark and unit tests, adding coverage reporting with codecov. Added pytest-cov to dev dependencies and configured Ruff linter settings in pyproject.toml.
Introduces detailed unit tests for the Assembler, Assembly, Joint, and Link classes in dlclive.core.inferenceutils. The new tests cover metadata parsing, detection flattening, link extraction, assembly building, Mahalanobis distance calculation, I/O helpers, and various Assembly operations, improving test coverage and reliability.
Corrects color sampling in Display to avoid zero step and ensures image is always defined in display_frame. Adds comprehensive tests for Display, including headless environment setup, frame display, cutoff logic, window destruction, and color sampling safety.
Removed the --no-cache flag from 'uv sync' in the testing workflow, enhanced pytest coverage reporting, and added a step to summarize coverage in the GitHub Actions job summary. Added a note in dynamic_cropping.py about duplication with another file and referenced existing tests.
Introduces a new 'pose' attribute to the DLCLive class, initialized as None or a numpy ndarray. This prepares the class for storing pose data.
sneakers-the-rat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it love it. We love tests. We love linting. I dont know too much about the code under test but gave a quick skim
Move test helpers into tests/conftest.py and introduce a suite of reusable pytest fixtures for assembler testing (headless_display_env, assembler graph/paf fixtures, scene factories, assembler/assembly/joint/link factories, and various canned dataset variants). Refactor tests/tests_core/test_assembler.py and tests/tests_core/test_assembly.py to consume the new fixtures, remove duplicated setup code, and simplify assertions. Also adjust serialization test filenames and tidy up identity/affinity-related test logic.
Replace handcrafted FakeTk/Label/PhotoImage classes with unittest.mock MagicMocks in the headless_display_env fixture. The fixture now returns a SimpleNamespace with mock constructors/instances (tk, label, photo) and sets display module attributes with monkeypatch (raising=False). Update tests to use the env mocks, assert on mock calls (title, pack, configure, update, destroy), mock ImageDraw.Draw with a MagicMock, and make colormap sampling deterministic for assertions. This simplifies test setup and enables precise call-based assertions instead of inspecting custom fake object state.
Replace tuple-based assembler fixtures with SimpleNamespace objects (providing .data, .graph, .paf_inds) and update all tests to access those attributes. Add Hypothesis to dev dependencies and introduce property-based tests for Assembly (from_array invariants and extent/area checks)
Introduce property-based tests for assembler utilities using Hypothesis: add test_condensed_index_properties for _conv_square_to_condensed_indices, a composite coords_and_conf strategy, test_flatten_detections_counts to validate _flatten_detections output counts, and a property test for extract_best_links (greedy) that asserts affinity, confidence-product (pcutoff) and disjointness invariants. Add Hypothesis imports, settings and numpy-array strategies. Also adjust test_assembly to ensure rows containing any NaN are set fully to NaN so the test matches Assembly.from_array behavior.
|
Thanks again @sneakers-the-rat for the feedback, I've tried to integrate it best as I could. I also checked out other tools to help with robustness such as |
Expanded testing suite, addressing some missing coverage. Adds coverage reporting to the CI.
Focuses on core functionalities testing, and avoids redundancy with main DLC codebase (but pends further centralization)
hypothesis-based testing to improve utility and robustness of testsMinor fixes of some missing attributes.
Flags code duplication from main DLC codebase (may not be exhaustive yet)
Remove CI changes for now
NOTE : Contains some CI/pre-commit changes, these can be removed before targeting main if we want them in a separate PR (but they will be used for formatting)This pull request includes several improvements and updates across the codebase and CI configuration. The main themes are: adding pre-commit hooks for code quality, updating the test workflow and coverage reporting, and refactoring the
dlclive/core/inferenceutils.pyfile for code clarity and modern Python standards.Continuous Integration and Code Quality:
.pre-commit-config.yamlfile to configure pre-commit hooks for docstring checks, whitespace cleanup, setup.cfg formatting, and Ruff linter/formatter..github/workflows/testing.ymlto use newer action versions, streamline dependency installation, and add code coverage reporting with Codecov. [1] [2] [3]Refactoring and Modernization of
dlclive/core/inferenceutils.py:tuple[float, float]instead ofTuple[float, float],zip(..., strict=False)for safer iteration). [1] [2] [3] [4] [5] [6] [7]stacklevelparameter for better tracebacks and improved readability of multi-line code blocks. [1] [2] [3]Documentation and Comments:
dlclive/core/inferenceutils.pyindicating that the file is a duplicate of the original DeepLabCut codebase, with author and date.