Skip to content
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

Reorganise test fixtures #380

Merged
merged 37 commits into from
Jan 31, 2025
Merged

Reorganise test fixtures #380

merged 37 commits into from
Jan 31, 2025

Conversation

lochhh
Copy link
Collaborator

@lochhh lochhh commented Jan 20, 2025

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
This PR closes #336 and #222.

What does this PR do?
This PR

  • modularises fixtures in conftest.py by grouping these as either datasets.py, files.py, or helpers.py in tests/fixtures/; where datasets contains fixtures for valid and invalid movement datasets and arrays, dataframes; helpers contain the helper functions to count nans and the reused assert_valid_dataset()
  • ensures file fixtures returning file paths are suffixed with "_file" to enable devs to easily identify file fixtures and search for existing ones
  • prefixes VIA tracks-related file content fixtures with via_
  • replaces the old and simpler valid_poses_dataset, valid_poses_dataset_with_nan, valid_position_array fixtures with the newer uniform_linear_motion fixtures and updates the affected tests
  • updates poses_with_nan fixture to match that of bboxes (i.e. both centroids have nans at the same time points)
  • ensures data fixtures containing nans are consistently suffixed with _with_nan (before we had a mix of _with_nans and _with_nan)
  • groups tests using the same "parametrize" into Classes, e.g. TestComputeKinematics, TestFilteringValidDataset
  • removes unused fixtures
  • standardises the "individuals" IDs across fixtures to start from id_0 (before, poses ids start from id_1); semi-related note: movement by default sets "individuals" names to begin with "individual_0" if none are provided upon import.
  • renames compute_time_derivative test to match new function name and parametrise expectations

I haven't changed the vector-related tests in test_kinematics.py as there is ongoing work in PR #385.

References

#336 #222

How has this PR been tested?

Tests passing

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.80%. Comparing base (84b245c) to head (8bd6ef1).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #380   +/-   ##
=======================================
  Coverage   99.80%   99.80%           
=======================================
  Files          15       15           
  Lines        1048     1048           
=======================================
  Hits         1046     1046           
  Misses          2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@niksirbi niksirbi linked an issue Jan 21, 2025 that may be closed by this pull request
@niksirbi
Copy link
Member

FYI @lochhh, @sfmig has arrived at a nice structure in ethology, by storing fixtures in separate files, see this PR.

I don't know of you were planning to go this deep into reorganising, leaving this reference here just in case its useful.

@lochhh lochhh requested a review from sfmig January 24, 2025 18:00
@lochhh lochhh marked this pull request as ready for review January 24, 2025 18:00
Copy link
Contributor

@sfmig sfmig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @lochhh it looks fantastic!

I really like the consistency (such as the _file endings, the via_ prefixes, with_nan suffixes etc), it makes a lot of it much more readable. I followed some of these ideas and suggested a few invalid_ prefixes for some dataset-related fixtures.

The only larger thing is that I had a go at moving the movement_dataset_asserts fixture to be under the helpers fixtures, since the class that wrapped it only had that one method - it's here, but you can revert if you disagree.

Re PR #385, since that is now merged, if you want to deal with that in this PR I am happy to review any additions. Otherwise we can deal with it separately in another PR/issue.

tests/conftest.py Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
tests/fixtures/data.py Outdated Show resolved Hide resolved
tests/fixtures/data.py Outdated Show resolved Hide resolved
tests/fixtures/data.py Outdated Show resolved Hide resolved
tests/test_unit/test_filtering.py Outdated Show resolved Hide resolved
tests/test_unit/test_kinematics.py Show resolved Hide resolved
tests/test_unit/test_kinematics.py Outdated Show resolved Hide resolved
tests/fixtures/data.py Outdated Show resolved Hide resolved
@niksirbi
Copy link
Member

Re PR #385, since that is now merged, if you want to deal with that in this PR I am happy to review any additions. Otherwise we can deal with it separately in another PR/issue.

Oops sorry, we merged it without looking here.
Whatever scheme you agree on should be also applied to the kinematics tests (after merging/rebasing from main).

@lochhh
Copy link
Collaborator Author

lochhh commented Jan 30, 2025

thanks @lochhh it looks fantastic!

I really like the consistency (such as the _file endings, the via_ prefixes, with_nan suffixes etc), it makes a lot of it much more readable. I followed some of these ideas and suggested a few invalid_ prefixes for some dataset-related fixtures.

The only larger thing is that I had a go at moving the movement_dataset_asserts fixture to be under the helpers fixtures, since the class that wrapped it only had that one method - it's here, but you can revert if you disagree.

Re PR #385, since that is now merged, if you want to deal with that in this PR I am happy to review any additions. Otherwise we can deal with it separately in another PR/issue.

Thanks for the thorough review and suggestions @sfmig ! I've adopted most suggestions and explained those that weren't. I also added your suggestion related to the renamed compute_time_derivative in this PR.

I briefly looked into PR #385 and there isn't any new additions to conf.py, meaning there aren't "shared fixtures" to be reorganised, so nothing within the scope of this PR.

@sfmig sfmig added this pull request to the merge queue Jan 31, 2025
Merged via the queue into main with commit 199f8f2 Jan 31, 2025
28 checks passed
@sfmig sfmig deleted the reorg-fixtures branch January 31, 2025 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants