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

Fix failing tests based on numpy v2 #2934

Merged
merged 3 commits into from
Jun 18, 2024
Merged

Fix failing tests based on numpy v2 #2934

merged 3 commits into from
Jun 18, 2024

Conversation

ankith26
Copy link
Member

@ankith26 ankith26 commented Jun 17, 2024

Using the ruff plugin suggested in NumPy 2.0 migration guide

(base_env) ankith@AnkithLaptop:~/mount/gitstuff/personal/pygame-community/pygame-ce$ ruff check . --select NPY201
test/pixelcopy_test.py:548:25: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `all` instead.
test/pixelcopy_test.py:556:25: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `all` instead.
test/pixelcopy_test.py:566:25: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `all` instead.
test/sndarray_test.py:31:25: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `all` instead.
test/sndarray_test.py:74:25: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `all` instead.
test/sndarray_test.py:113:25: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `all` instead.
test/surfarray_test.py:238:33: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `all` instead.
test/surfarray_test.py:246:17: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `all` instead.
test/surfarray_test.py:260:21: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `all` instead.
test/surfarray_test.py:265:21: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `all` instead.
test/surfarray_test.py:293:29: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `all` instead.
Found 11 errors.
[*] 11 fixable with the `--fix` option.

Fixed all these issues by replacing the alltrue import with the all import, now aliased to np_all to prevent name collision with python's builtin all.

Also fixed a few incorrect sndarray testcases and added a skip for a failing surfarray test (we will deal with it in the future)

PS: the numpy.all function is numpy v1 API, so now our tests can run on both numpy v1 and numpy v2

@ankith26 ankith26 requested a review from a team as a code owner June 17, 2024 09:47
@ankith26 ankith26 changed the title Replace np.alltrue with np.all for np v2 support Replace np.alltrue with np.all, fix some incorrect sndarray testcases for np v2 support Jun 17, 2024
@ankith26 ankith26 changed the title Replace np.alltrue with np.all, fix some incorrect sndarray testcases for np v2 support Fix failing tests based on numpy v2 Jun 18, 2024
@zoldalma999 zoldalma999 merged commit 3ed89fe into main Jun 18, 2024
38 checks passed
@zoldalma999 zoldalma999 added this to the 2.5.1 milestone Jun 18, 2024
@ankith26 ankith26 deleted the ankith26-np-v2 branch June 18, 2024 17:32
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

Successfully merging this pull request may close these issues.

3 participants