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
Remove references to deprecated NumPy type aliases. #22965
Conversation
Do we want to backport to 3.4 ? I am not sure on the Numpy version that is supported there. |
Yes, backport to 3.4 is useful too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to keep these types in test_misc.py
, but protect them with version check. Otherwise inaccurate refactoring of conversion code might break something for older versions of NumPy, because coverage is reduced.
@VadimLevin , how would you protect them with version check knowing that np.float (for example) is not defined anymore ? |
Just several thoughts:
|
I believe the build error is unrelated: https://pullrequest.opencv.org/buildbot/builders/precommit_windows64/builds/100389/steps/test_python2/logs/stdio |
Drive-by comment: you can probably just write |
@hawkinsp , do you have a link for that please ? It would make this PR simpler. Thx |
The release notes of NumPy 1.20 note these type aliases have existed for a "long time". I don't know how far back they go! I personally verified the types are aliases as far back as NumPy 1.15.0 which was released in 2018:
I don't have an older copy of Python to try older NumPy versions, but I think it's safe to assume they existed before that. So if I were you I think I'd be quite comfortable just writing |
Thx a bunch @hawkinsp ! @VadimLevin , can I revert to what I did initially ? Just np.* -> * ? Thx |
I checked OpenCV-Python package. The minimum supported Numpy version is 1.13.3. Python 3.6 + Numpy 1.13.3 handles array names without "np." suffix correctly:
So you can just remove package name from types. |
Thanks @hawkinsp and @asmorkalov. @vrabaud Yep, sounds good. So just remove duplicates from test cases e.g. |
There are more failed tests, if per-module tests are enabled. Command example:
|
Also strange failure in core things:
|
@VadimLevin could you take a look on it? |
@vrabaud I added couple of more fixes to your PR. |
@asmorkalov , thx ! |
@vrabaud Please ignore my previous message about errors. I fould yet another OpenCV-Python instance. |
1090eab
to
50a9844
Compare
@vrabaud @VadimLevin I fixed double/float issue and squashed commits. Please take a look ASAP. |
This change replaces references to a number of deprecated NumPy type aliases (np.bool, np.int, np.float, np.complex, np.object, np.str) with their recommended replacement (bool, int, float, complex, object, str). Those types were deprecated in 1.20 and are removed in 1.24, cf numpy/numpy#22607.
50a9844
to
ad568ed
Compare
This change replaces references to a number of deprecated NumPy type aliases (np.bool, np.int, np.float, np.complex, np.object, np.str) with their recommended replacement (bool, int, float, complex, object, str).
Those types were deprecated in 1.20 and are removed in 1.24, cf numpy/numpy#22607.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request