orix
orix copied to clipboard
Moved to and from class methods from Rotation to Quaternion
Description of the change
Because of discussions in #401, #345 and #373, it seemed like there is a need to move the to_ and from_ methods of Rotation to the Quaternion class. And so I have copy pasted them over.
I have changed little to nothing about the methods themselves, other than changing names of variables and updated docstrings.
I did not move the random_vonmises() method as that would also require the angle_with method of Rotation class to be moved as well, and I was unsure whether that should be done or not.
I included an override of from_euler in Rotation to keep the proper vs improper rotation notion as it was originally.
Progress of the PR
- [x] Docstrings for all functions
- [x] Unit tests with pytest for all lines
- [x] Clean code style by running black via pre-commit
Minimal example of the bug fix or new feature
>>> from orix.quaternion import Quaternion, Rotation
>>> import numpy as np
>>> euler = np.random.rand(10, 3)
>>> rot = Rotation.from_euler(euler)
>>> quat = Quaternion.from_euler(euler)
For reviewers
- [ ] The PR title is short, concise, and will make sense 1 year later.
- [ ] New functions are imported in corresponding
__init__.py. - [ ] New features, API changes, and deprecations are mentioned in the unreleased
section in
CHANGELOG.rst. - [ ] Contributor(s) are listed correctly in
__credits__inorix/__init__.pyand in.zenodo.json.