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

General validator function for checking dimensions and coordinates #294

Merged
merged 11 commits into from
Sep 17, 2024

Conversation

niksirbi
Copy link
Member

@niksirbi niksirbi commented Aug 29, 2024

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

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:

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

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.

Copy link

codecov bot commented Aug 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

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

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

Copy link
Collaborator

@lochhh lochhh left a comment

Choose a reason for hiding this comment

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

Thanks @niksirbi ! This is a great start to the much needed validators module. The updated suggestions are minor - happy for you to take or leave.
While this PR aims to address #291 as well, I have a different opinion on this and have detailed it there.

movement/analysis/kinematics.py Outdated Show resolved Hide resolved
movement/analysis/kinematics.py Show resolved Hide resolved
movement/analysis/kinematics.py Outdated Show resolved Hide resolved
movement/analysis/kinematics.py Outdated Show resolved Hide resolved
movement/analysis/kinematics.py Show resolved Hide resolved
movement/analysis/kinematics.py Show resolved Hide resolved
tests/test_unit/test_validators/test_array_validators.py Outdated Show resolved Hide resolved
tests/test_unit/test_validators/test_array_validators.py Outdated Show resolved Hide resolved
@niksirbi
Copy link
Member Author

niksirbi commented Sep 16, 2024

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.

@niksirbi niksirbi linked an issue Sep 16, 2024 that may be closed by this pull request
@niksirbi niksirbi requested a review from lochhh September 16, 2024 19:08
@lochhh lochhh force-pushed the general-dim-coord-validator branch from bd317e6 to c36daf1 Compare September 17, 2024 13:10
@lochhh lochhh force-pushed the general-dim-coord-validator branch from c36daf1 to 3411419 Compare September 17, 2024 13:12
Copy link

@lochhh
Copy link
Collaborator

lochhh commented Sep 17, 2024

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.

@lochhh lochhh added this pull request to the merge queue Sep 17, 2024
Merged via the queue into main with commit 9c80786 Sep 17, 2024
23 checks passed
@niksirbi
Copy link
Member Author

Thanks @lochhh! Nice final touches.

@niksirbi niksirbi deleted the general-dim-coord-validator branch September 17, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants