-
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
| return frame | ||
|
|
||
|
|
||
| def simple_two_label_scene(): |
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.
These helpers might be nice to have as fixtures :)
| assert "confidence" in asm[0] | ||
| assert "costs" in asm[0] | ||
|
|
||
| # empty() convenience |
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.
Maybe a separate test? Is empty related to the above parsing behavior?
| # -------------------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| def test_build_assemblies_from_links(): |
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.
Yes yes as you go, if you put the repeated setup steps in fixtures, then the test bodies can contain only the behavior under test. You can parameterize the fixtures by making them closures (function that returns a function) or with pytest's indirect fixture parameterization :)
| a2.add_link(l23) | ||
|
|
||
| # now they share NO joints → addition should succeed | ||
| result = a1 + a2 |
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.
Oh this is a nice behavior!
|
|
||
| # now purposely make them share a joint → should raise | ||
| a2.add_joint(j0) | ||
| with pytest.raises(ArithmeticError): |
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.
Haha love the error category choice
| pose = np.array([[[5, 5, 0.9]]]) | ||
|
|
||
| disp.display_frame(frame, pose) | ||
| disp.destroy() |
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.
These get a little circular, if youre testing that a method is called, you can do so without later risking youre just testing your mocked classes using the MagicMocks and expectations
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)
Minor 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 introduces a pre-commit configuration and makes a series of code quality, formatting, and workflow improvements, particularly targeting the
dlclive/core/inferenceutils.pymodule and the GitHub Actions testing workflow. The changes focus on code consistency, improved warnings, and enhanced test coverage reporting.Workflow and Testing Improvements
actions/checkoutstep in.github/workflows/testing.ymlfrom v4 to v6 and removed the--no-cacheflag fromuv syncto streamline dependency installation. [1] [2]Code Quality and Formatting
.pre-commit-config.yamlfile to enforce code style and linting using pre-commit hooks (docstring checks, EOF fixer, trailing whitespace, setup-cfg formatting, and Ruff for linting/formatting).dlclive/core/inferenceutils.py(e.g., single-line comprehensions, compact function calls, and more concise warnings). [1] [2] [3] [4] [5] [6] [7] [8] [9]Behavioral and Compatibility Adjustments
strict=Falsetozip()calls and dictionary constructions to ensure compatibility with Python 3.10+ and prevent errors when input iterables are of different lengths. [1] [2] [3] [4] [5]stacklevel=2for better traceability of the warning origin. [1] [2] [3]Documentation and Typing
dlclive/core/inferenceutils.pyindicating that the file is duplicated from the original DeepLabCut codebase.PositionfromTuple[float, float]totuple[float, float]and updating imports to usecollections.abc.Iterable. [1] [2]