Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix *most of* the Deprecation Warnings in surfarray_test #3274

Merged
merged 3 commits into from
Dec 31, 2024

Conversation

MyreMylar
Copy link
Member

Noticed that there were several fixable Deprecation Warnings coming out of our surfarray tests.

I feel in general that we should try and minimise the outputting of 'expected' warnings from our tests so that we are more likely to find the unexpected ones when running a full test run.

I spotted the warnings by running:

pytest test/surfarray_test.py -s

There are two main fixes applied:

  1. Using..
with self.assertWarns(DeprecationWarning):

as a context manager when we are deliberately calling a deprecated function at the moment - we can remove tests like this if/when the deprecated function itself is finally removed.

  1. Applying the recommendation from Numpy's deprecation warning where we have deprecated behaviour:
DeprecationWarning: NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays.  The conversion of -10185016 to uint32 will fail in the future.
  For the old behavior, usually:
      np.array(value).astype(dtype)
  will give the desired result (the cast overflows).
    arr[:5, 6:] = surf.map_rgb(palette[3])

@MyreMylar MyreMylar requested a review from a team as a code owner December 30, 2024 15:48
Copy link
Member

@damusss damusss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix, thanks :3

Ankith believes we can fix this better in the library code.
@MyreMylar MyreMylar changed the title Fix the Deprecation Warnings in surfarray_test Fix *most of* the Deprecation Warnings in surfarray_test Dec 31, 2024
Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! 🎉

@ankith26 ankith26 added this to the 2.5.3 milestone Dec 31, 2024
@ankith26 ankith26 merged commit c4eba16 into main Dec 31, 2024
24 checks passed
@ankith26 ankith26 deleted the remove-deprecated-surfarray-funcs-from-tests branch December 31, 2024 10:46
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants