scikit-hep / scikit-hep/vector
`scipy.spatial.transform.Rotation` Integration
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 99
- Forks
- 42
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 6
Description
Vector Version
1.1.1.post1
Python Version
3.10.9
OS / Environment
OS: KAli Linux 2023.3
Environment: scipy==1.11.1
Describe the bug
First of all thanks for the awesome work on the library
there are some errors with Rotation.apply
these are some ways to reproduce
from scipy.spatial.transform import Rotation
from vector import VectorObject3D, VectorNumpy3D
v_object = VectorObject3D(x=1, y=0, z=0)
v_array = VectorNumpy3D({"x": [1], "y": [0], "z": [0]})
r = Rotation.from_quat((0, 0, 1, 1))
# _r = r.as_quat()
# print(v.rotate_quaternion(_r[3], _r[0], _r[1], _r[2]))
# Returns: VectorObject3D(x=0.0, y=0.9999999999999998, z=0.0)
# print(r.apply(v_object)) # Raises: IndexError(tuple index out of range)
print(r.apply(v_object.__array__().tolist()))
# Returns: [0. 1. 0.]
# print(r.apply(v_array)) # Raises: ValueError(Expected input of shape (3,) or (P, 3), got (1,).)
print(r.apply(v_array.tolist()))
# Returns: [[0. 1. 0.]]
I think it would be a good idea to add rotate method to Vector that accepts the Rotation instance as input and applies the rotation on Vector
from scipy.spatial.transform import Rotation
def rotate(self, rot: Rotation):
pass
Any additional but relevant log output
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduced scipy.spatial.transform.Rotation.apply calls and inspect the VectorObject3D and VectorNumpy3D interfaces. Compare the direct Rotation inputs with the working array-list inputs, then define completion as Rotation instances being accepted for both vector forms with the shown rotations producing the expected results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100