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

Add tests for heading angle #385

Merged
merged 18 commits into from
Jan 28, 2025
Merged

Conversation

willGraham01
Copy link
Contributor

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?

Builds on top of #376, adding the necessary tests as well as reorganising the functionality that the base branch intends to introduce.

What does this PR do?

  • Adds tests for the validate_reference_vector function
  • "Mathmaticises" the compute_signed_angle_2d function, turning it into a mathematical implementation that is designed to be wrapped by higher-level, user-friendly functions.
    • The definition of the signed angle is also standardised and clearly stated in the function docstring, to minimise confusion.
    • Tests for this function are added.
  • Adjusts the call signature of the higher-level compute_forward_vector_angle (called compute_heading_angle in the base branch) to accommodate the possibility of different conventions for the angle sign.

References

Builds on #376, with a view to merging the quoted PR after this one.

How has this PR been tested?

  • Local test suite updated and passing.
  • Pre-commit is happy.

Is this a breaking change?

No.

Does this PR require an update to the documentation?

No.

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

willGraham01 and others added 4 commits January 21, 2025 12:00
* Implement the expected fix

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.8.1 → v0.8.6](astral-sh/ruff-pre-commit@v0.8.1...v0.8.6)
- [github.com/pre-commit/mirrors-mypy: v1.13.0 → v1.14.1](pre-commit/mirrors-mypy@v1.13.0...v1.14.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Revert "Implement the expected fix"

This reverts commit edbaa9c.

* Update method to explicitly construct and drop spatial z dimensions

* Force nan test to check for preserved coordinates

* Force explicit coordinate preservation checks in input/output test

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.80%. Comparing base (fc30b5a) to head (49a6620).
Report is 13 commits behind head on ns-heading-angle.

Additional details and impacted files
@@                 Coverage Diff                  @@
##           ns-heading-angle     #385      +/-   ##
====================================================
+ Coverage             99.79%   99.80%   +0.01%     
====================================================
  Files                    14       14              
  Lines                   969     1025      +56     
====================================================
+ Hits                    967     1023      +56     
  Misses                    2        2              

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

@willGraham01 willGraham01 marked this pull request as ready for review January 24, 2025 17:51
@willGraham01 willGraham01 requested a review from niksirbi January 24, 2025 17:51
@lochhh lochhh mentioned this pull request Jan 27, 2025
7 tasks
Copy link
Member

@niksirbi niksirbi left a comment

Choose a reason for hiding this comment

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

Very well done @willGraham01!

I'm happy with this implementation and I'm in awe of how thoroughly and creatively you've tested the functionality.

I've mostly just pointed out some pedantic naming issues and some Sphinx rst-related formatting issues. Feel free to adopt or push back.

movement/validators/vector.py Outdated Show resolved Hide resolved
movement/kinematics.py Outdated Show resolved Hide resolved
movement/validators/vector.py Outdated Show resolved Hide resolved
movement/validators/vector.py Outdated Show resolved Hide resolved
movement/kinematics.py Outdated Show resolved Hide resolved
movement/kinematics.py Outdated Show resolved Hide resolved
movement/kinematics.py Outdated Show resolved Hide resolved
movement/kinematics.py Show resolved Hide resolved
tests/test_unit/test_validators/test_vector_validators.py Outdated Show resolved Hide resolved
tests/test_unit/test_kinematics.py Outdated Show resolved Hide resolved
Copy link

@willGraham01 willGraham01 merged commit ac22354 into ns-heading-angle Jan 28, 2025
28 checks passed
@willGraham01 willGraham01 deleted the wgraham-heading-angle-tests branch January 28, 2025 10:32
github-merge-queue bot pushed a commit that referenced this pull request Jan 28, 2025
* Basic implementation of `compute_heading()` and `compute_relative_heading()`

* Minor fixes and docstring edits

* Remove `compute_relative_heading()` from this PR

* Created `signed_angle_between_2d_vectors()` vector util and refactored `compute_heading()`

* Cleaned up redundant code

* get rid of analysis folder

* add exact_coords boolean to the validator for dims and coords

* adapted reference vector validator

* renamed compute_heading to compute_heading_angle

* fixed docstring formatting errors

* renamed new vector util to compute_signed_angle_2d

* Add tests for heading angle (#385)

* Breakout vector valiadator with skeleton test

* Write validator tests, fix bug in missing .get method

* Fix dims and coords returned by `compute_forward_vector` (#382)

* Implement the expected fix

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.8.1 → v0.8.6](astral-sh/ruff-pre-commit@v0.8.1...v0.8.6)
- [github.com/pre-commit/mirrors-mypy: v1.13.0 → v1.14.1](pre-commit/mirrors-mypy@v1.13.0...v1.14.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Revert "Implement the expected fix"

This reverts commit edbaa9c.

* Update method to explicitly construct and drop spatial z dimensions

* Force nan test to check for preserved coordinates

* Force explicit coordinate preservation checks in input/output test

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Standardise compute_signed_angle_2d function as a purely mathematical impementation

* Patch up compute_forward_vector_angle

* Start on tests but encounter NaN bug that needs rebase fix

* Fix mapping of -pi to pi in signed_angle

* Write antisymmetry test

* Write invariance under transforms test

* Add tests for missing lines

* Apply batch suggestions from code review

Co-authored-by: Niko Sirmpilatze <[email protected]>

* Fix computer_forward_vector__angle docstring

* Remove unnecessary validation checks

* Use camera view variable name for codebase consistency

* Fix validator docstring backticks

* Move ref vector validator into array validators

* Fix typehints and test broken by removing earlier error check

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Niko Sirmpilatze <[email protected]>

---------

Co-authored-by: b-peri <[email protected]>
Co-authored-by: Will Graham <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants