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 from_attitude class method for more permissive init #39

Merged
merged 2 commits into from
Oct 25, 2021

Conversation

taldcroft
Copy link
Member

Description

This allows more permissive initialization of a Quaternion for cases when the input is known to be an attitude (instead of e.g. a 3x3 transform).

Testing

  • Passes unit tests on MacOS (with new tests)
  • [n/a] Functional testing

Copy link
Contributor

@javierggt javierggt left a comment

Choose a reason for hiding this comment

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

Looks fine. I added just a few minor comments.

Attitude(s) as a Quat
"""
if isinstance(att, Quat):
return att
Copy link
Contributor

Choose a reason for hiding this comment

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

In all the other cases below, this function returns a new object, while here it returns the same input object. Should we be consistent and return a copy always?

One way this can backfire is when the user creates quaternions within a loop, from a single quaternion instance. All "new" quaternions will actually be a pointer to the same one instance (which will have values from the last iteration).

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, will fix.

except Exception:
pass
else:
return att
Copy link
Contributor

Choose a reason for hiding this comment

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

This line was not covered in tests, according to coverage.py.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Attitude(s) as a Quat
"""
if isinstance(att, Quat):
return att
Copy link
Contributor

Choose a reason for hiding this comment

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

This line was not covered in tests, according to coverage.py.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@taldcroft
Copy link
Member Author

Thanks, I think I addressed all comments.

@taldcroft taldcroft requested a review from javierggt October 25, 2021 20:37
@taldcroft taldcroft merged commit 84eb7d0 into master Oct 25, 2021
@taldcroft taldcroft deleted the from-attitude branch October 25, 2021 20:58
@javierggt javierggt mentioned this pull request Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants