-
Notifications
You must be signed in to change notification settings - Fork 12
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #380 +/- ##
=======================================
Coverage 99.79% 99.79%
=======================================
Files 14 14
Lines 969 969
=======================================
Hits 967 967
Misses 2 2 ☔ View full report in Codecov by Sentry. |
cc622b9
to
978c8b3
Compare
7c0b12c
to
7acf596
Compare
60b3e50
to
253a8ea
Compare
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.
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.
* expected_n_nans_in_position | ||
@pytest.mark.parametrize( | ||
"window", | ||
[3, 5, 6, 10], # data is nframes = 10 |
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.
[3, 5, 6, 10], # data is nframes = 10 | |
[3, 5, 6, 10], # input data has 10 frames |
- id_1 moves along x=-y line from the origin | ||
- they both move one unit (pixel) along each axis in each frame | ||
class TestComputeKinematics: | ||
"""Test ``compute_[kinematic_variable]`` with valid and invalid inputs.""" |
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.
"""Test ``compute_[kinematic_variable]`` with valid and invalid inputs.""" | |
"""Test ``compute_[kinematic_variable]`` with valid and invalid inputs. | |
When valid, the expected kinematics are a uniform linear motion case. | |
Uniform linear motion means the individuals move along a line at constant | |
velocity. | |
We consider 2 individuals ("id_0" and "id_1"), tracked for 10 frames, | |
along x and y: | |
- Individual 0 ("id_0") moves along x=y line from the origin | |
- Individual 1 ("id_1") moves along x=-y line from the origin | |
- they both move one unit (pixel) along each axis in each frame | |
""" |
I think this description may have got lost somewhere
"""Test kinematics computation with an invalid dataset.""" | ||
with expected_exception: | ||
position = request.getfixturevalue(invalid_dataset).position | ||
getattr(kinematics, f"compute_{kinematic_variable}")(position) | ||
|
||
|
||
@pytest.mark.parametrize("order", [0, -1, 1.0, "1"]) |
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.
Below a suggestion I realise that is out of scope for this PR - if you want it can be dealt separately. It involves:
- renaming the test (it refers to the old name of the function I think)
- include the expected exception in the parametrisation for readability
@pytest.mark.parametrize(
"order, expected_exception",
[
(0, pytest.raises(ValueError)),
(-1, pytest.raises(ValueError)),
(1.0, pytest.raises(TypeError)),
("1", pytest.raises(TypeError)),
],
)
def test_time_derivative_with_invalid_order(order, expected_exception):
"""Test that an error is raised when the order is non-positive."""
data = np.arange(10)
with expected_exception:
kinematics.compute_time_derivative(data, order=order)
Oops sorry, we merged it without looking here. |
Quality Gate passedIssues Measures |
Description
What is this PR
Why is this PR needed?
This PR closes #336 and #222.
What does this PR do?
This PR
data.py
,files.py
, orhelpers.py
intests/fixtures/
; where data contains fixtures for valid and invalid movement datasets and arrays, dataframes, and themovement_dataset_asserts
.file
fixtures returning file paths are suffixed with "_file" to enable devs to easily identify file fixtures and search for existing onesvia_
valid_poses_dataset
,valid_poses_dataset_with_nan
,valid_position_array
fixtures with the neweruniform_linear_motion
fixtures and updates the affected testsposes_with_nan
fixture to match that of bboxes (i.e. both centroids have nans at the same time points)data
fixtures containing nans are consistently suffixed with_with_nan
(before we had a mix of_with_nans
and_with_nan
)TestComputeKinematics
,TestFilteringValidDataset
id_0
(before, poses ids start fromid_1
); semi-related note: movement by default sets "individuals" names to begin with "individual_0" if none are provided upon import.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: