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

Fix Angle.__abs__ such that it always returns a positive value #763

Merged
merged 1 commit into from
Jan 30, 2023

Conversation

erogers-dstl
Copy link
Contributor

Address part of issue #749 that deals with Bearings not playing nicely with numpy.isclose, which is due to abs(Bearing(-pi)) returning a negative value.

@erogers-dstl erogers-dstl requested a review from a team as a code owner January 20, 2023 09:58
@erogers-dstl erogers-dstl requested review from jswright-dstl and nperree-dstl and removed request for a team January 20, 2023 09:58
@erogers-dstl
Copy link
Contributor Author

Note that (as per the comment in the source file), there is still the oddity that abs(Bearing(-pi)) != Bearing(+pi)) or equivalently that abs(Bearing(-pi)) != Bearing(abs(-pi)))

This is because abs(Bearing(-pi)) == pi (because abs forces it positive) and Bearing(abs(-pi)) == -pi (because the bearing modulo operation pushes pi to be stored as -pi).

Copy link
Contributor

@edwheelhouse-dstl edwheelhouse-dstl left a comment

Choose a reason for hiding this comment

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

Fine. The oddity is annoying, but hopefully it won't come up often!

@erogers-dstl erogers-dstl mentioned this pull request Jan 24, 2023
@sdhiscocks sdhiscocks added the bug label Jan 30, 2023
@sdhiscocks sdhiscocks merged commit adff89b into main Jan 30, 2023
@sdhiscocks sdhiscocks deleted the angle-abs-fix branch January 30, 2023 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants