Closed Jiayuan-Gu closed 2 years ago
Good point. But - would you consider adding a test?
I can add one. But do you mean adding a fully new test in https://github.com/matthew-brett/transforms3d/blob/master/transforms3d/tests/test_euler.py? My fix looks too simple to add a test.
The test would just be passing an array, checking the result is correct, and checking the initial array had not been modified ...
import numpy as np
from transforms3d.euler import euler2quat
def test_euler2quat_inplace():
angle = np.array(1.0)
euler2quat(0, 0, angle)
np.testing.assert_allclose(angle, 1.0)
test_euler2quat_inplace()
Thanks - yes - although it would be good to test all three input arguments. Would you mind adding this to the tests?
I've added the unit test. I find the issue happens especially for the case np.array(1.0)
(which is a np.ndarray), but not for the case like np.random.rand(3)[0]
(which is a np.float64).
Remove in-place modification.
If a NumPy array is passed into
euler2quat
, then it will lead to unexpected behaviors.