AngleAxis and getunit error with Numpy 2.4

Đang mở
#177 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
50/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
numpy, python
Lĩnh vực
backend

Hướng nghiên cứu

Reproduce the SO3.AngVec(theta=0, v=[0, 0, 1]) failure with NumPy 2.4, then inspect spatialmath/pose3d.py and spatialmath/base/transforms3d.py, including getunit and angvec2r. Done means the call no longer raises a TypeError under NumPy 2.4 and retains the expected identity rotation behavior.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Hi,

When calling SO3.AxisAngle in Python 3.11 with numpy 2.4, I get the error:

Python 3.11.11 | packaged by conda-forge | (main, Dec  5 2024, 08:47:03) [Clang 18.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.__version__
'2.4.0'
>>> from spatialmath import SO3
>>> SO3.AngVec(theta=0, v=[0, 0, 1])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/Caskroom/miniconda/base/envs/vp_311/lib/python3.11/site-packages/spatialmath/pose3d.py", line 825, in AngVec
    return cls(smb.angvec2r(theta, v, unit=unit), check=False)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniconda/base/envs/vp_311/lib/python3.11/site-packages/spatialmath/base/transforms3d.py", line 760, in angvec2r
    R = np.eye(3) + math.sin(θ) * sk + (1.0 - math.cos(θ)) * sk @ sk
                    ^^^^^^^^^^^
TypeError: only 0-dimensional arrays can be converted to Python scalars
>>> 

However, with numpy 2.2, I get the expected behavior:

Python 3.11.11 | packaged by conda-forge | (main, Dec  5 2024, 08:47:03) [Clang 18.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.__version__
'2.2.6'
>>> from spatialmath import SO3
>>> SO3.AngVec(theta=0, v=[0, 0, 1])
SO3(array([[1., 0., 0.],
           [0., 1., 0.],
           [0., 0., 1.]]))

The error seems to stem from getunit, which when given a scalar now returns a 1-dimensional array instead of a 0-dimensional array. That then gets fed to math.cos, not np.cos, in angvec2r and the error occurs.

Thank you for all your work on this library,
JF

Ngôn ngữ chính
Python
Star
641
Fork
102
Merge trung bình
1 ngày 18 giờ
Pull request đã merge (30 ngày)
4

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rai-opensource/spatialmath-python

Tất cả issue của rai-opensource/spatialmath-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.