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

from_rotation_vector error #239

Closed
balazon opened this issue Oct 29, 2024 · 2 comments
Closed

from_rotation_vector error #239

balazon opened this issue Oct 29, 2024 · 2 comments

Comments

@balazon
Copy link

balazon commented Oct 29, 2024

Describe the bug
from_rotation_vector(..) crashes with numpy >= 2.0
This is not a problem when I downgrade numpy to 1.x (1.26.4)

Traceback (most recent call last):
  File "/home/ad.adasworks.com/balint.varga/work/egoside/test_quat.py", line 4, in <module>
    quaternion.from_rotation_vector([0, 0.3, 0])
  File "/home/ad.adasworks.com/balint.varga/miniforge3/envs/quattest/lib/python3.12/site-packages/quaternion/__init__.py", line 459, in from_rotation_vector
    rot = np.array(rot, copy=False)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.

To Reproduce

import quaternion

if __name__ == "__main__":
    quaternion.from_rotation_vector([0, 0.3, 0])

Expected behavior
I would expect no crash

Environment

  • OS: ubuntu 22.04
  • Installation method: pip (happens with conda too)
  • Numpy version 2.0.2
  • Quaternion version 2024.0.2

I don't know anything about how numpy 2.0 might break things, but from what I can see, there was already a lot of development by you guys to support numpy 2.0, maybe this was missed?
Could you check please?

I also see there is the new quaternionic pure python library. Would you recommend to use that instead of numpy-quaternion?

@moble moble changed the title from_rotation_vector crash from_rotation_vector error Oct 29, 2024
@moble
Copy link
Owner

moble commented Oct 29, 2024

Thanks for reporting this. I hadn't noticed that they changed the meaning of the word "copy" in numpy 2.0. 🙄 I'll fix this and look for similar issues.

from_rotation_vector(..) crashes with numpy >= 2.0

Just a little nitpick: "crash" usually refers to something more serious involving memory corruption or something really bad like that, so it's pretty alarming to see that word used. This is just an error.

I also see there is the new quaternionic pure python library. Would you recommend to use that instead of numpy-quaternion?

Yeah, it's easier for a lot of reasons. I think this one is more popular just because it's been around for so long. But I tend to use quaternionic more myself.

moble added a commit that referenced this issue Oct 29, 2024
@moble moble closed this as completed in 7db8c5d Oct 29, 2024
@balazon
Copy link
Author

balazon commented Oct 30, 2024

Hi, Sorry about the alarming "crash", I just meant crash in the sense that program execution stopped. I guess you're right, error is more accurate here.
I'll check out quaternionic sometime, thanks for the tip, and also for the quick fix on this

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

No branches or pull requests

2 participants