Closed jaku-jaku closed 10 months ago
Can one of the admins verify this patch?
Does this have backwards compatibility? What version of OS / libs are you using?
Does this have backwards compatibility? What version of OS / libs are you using?
OS: Ubuntu 20.04 | ROS Noetic | Python 3.8.10 | numpy: 1.24.1
import numpy as np
np.float
Output:
AttributeError: module 'numpy' has no attribute 'float'
As stated in numpy 1.20 - deprecations, it will be no longer supported due to duplication. Hence, I believe it is not backward compatible from numpy 1.20
@goldbattle are there plans to merge this PR?
I have not had time to reproduce in a docker container and ensure it has backwards compatibility. Need to also verify that this is the only place that needs it, and likely create a ubuntu 22 docker.
I have not had time to reproduce in a docker container and ensure it has backwards compatibility. Need to also verify that this is the only place that needs it, and likely create a ubuntu 22 docker.
Try to check your numpy version in your docker.
I think is to do with numpy version, either add requirements.txt to enforce numpy<1.20.0
, or apply this changes with 'numpy>=1.20.0'.
As refer from https://stackoverflow.com/questions/74844262/how-can-i-solve-error-module-numpy-has-no-attribute-float-in-python
NumPy 1.20 (release notes) deprecated numpy.float, numpy.int, and similar aliases, causing them to issue a deprecation warning NumPy 1.24 (release notes) removed these aliases altogether, causing an error when they are used
I will make a test locally and update this PR with backward support
pip3 install numpy==1.24
now run calibration:
File "{my-path}/kalibr/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/CameraUtils.py", line 123, in getReprojectionErrorStatistics
mean = np.mean(rerr_matrix, 0, dtype=np.float)
File "{my-home}/.local/lib/python3.8/site-packages/numpy/__init__.py", line 284, in __getattr__
raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'float'
Fixes tested:
Python 3.8.10 (default, May 26 2023, 14:05:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.float
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jx/.local/lib/python3.8/site-packages/numpy/__init__.py", line 284, in __getattr__
raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'float'
>>> numpy.float64
<class 'numpy.float64'>
>>> numpy.version.version
'1.24.0'
and backward $ pip3 install numpy==1.17.4
Python 3.8.10 (default, May 26 2023, 14:05:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.float
<class 'float'>
>>> numpy.float64
<class 'numpy.float64'>
>>> numpy.version.version
'1.17.4'
@adthoms @goldbattle Done, and tested for backward and forward compatible.
You can replicate the above issue on the main branch by pip install numpy==1.24
, and you will see the error.
You can remove the issue by setting pip install numpy==1.23
or specify np.float64
(with this latest fix)
Many thanks for the detailed PR and steps to test, was able to reproduce and this PR fixed the issues. Many thanks.