neuroinformatics-unit / movement

Python tools for analysing body movements across space and time
http://movement.neuroinformatics.dev
BSD 3-Clause "New" or "Revised" License
96 stars 8 forks source link

General validator function for checking dimensions and coordinates #294

Closed niksirbi closed 2 weeks ago

niksirbi commented 1 month ago

Description

What is this PR

Why is this PR needed? See #292 and #291

What does this PR do? Turns a previously private function for validating the existence of dimensions and coordinates into a public function in validators/arrays.py/validate_dims_coords. This function is then used in both kinematics.py and vector.py. In kinematics, it's now also used to assert cartesian coordinates for computing displacement, velocity and acceleration.

How has this PR been tested?

Existing test were already indirectly covering this functionality, but I decided to also add some unit tests that directly test this new validator. These tests are also much stricter in checking that the thrown exception has the right error message.

Is this a breaking change?

Nope.

Does this PR require an update to the documentation?

No, API docs will be automatically updated.

Checklist:

Update 2024-09-16

This PR also exposes compute_time_derivative as a public function, and thus closes #311, following discussions in #291. This function is not restricted to Cartesian space.

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.77%. Comparing base (644c1b1) to head (3411419). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #294 +/- ## ======================================= Coverage 99.77% 99.77% ======================================= Files 14 15 +1 Lines 884 887 +3 ======================================= + Hits 882 885 +3 Misses 2 2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

niksirbi commented 2 weeks ago

Thanks for the review @lochhh!

I've addressed your comments, and I've additionally exposed compute_time_derivative as a public function, as discussed in #291. So this PR now additionally closes #311.

Re-requesting review to double-check that you're happy with the way the new public function works.

sonarcloud[bot] commented 2 weeks ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

lochhh commented 2 weeks ago

Thanks for the review @lochhh!

I've addressed your comments, and I've additionally exposed compute_time_derivative as a public function, as discussed in #291. So this PR now additionally closes #311.

Re-requesting review to double-check that you're happy with the way the new public function works.

Thanks again @niksirbi . Made a couple of small changes: refactor test + update old refs to xr.differentiate in compute_velocity and compute_acceleration to point directly to the newly exposed compute_time_derivative.

niksirbi commented 2 weeks ago

Thanks @lochhh! Nice final touches.