Skip to content

Conversation

@Zeitsperre
Copy link
Collaborator

@Zeitsperre Zeitsperre commented May 7, 2025

Description

This Pull Request addresses several previous DeprecationWarnings that are fully deprecated in more modern version of numpy and scikit-learn. It also suppresses several warnings raised by numpy during the testing suite. This adds a pin on numpy (v1.25+) and numba (v0.57+).

I've also removed the suppress_warnings() function, as the number of possible RuntimeWarnings was beyond reasonable, especially when comparing older and newer scientific Python libraries (different categorizations were possible). The warnings.filter(RuntimeWarning) approach is more powerful.

It also simplifies the complete installation recipe by reusing the xskillscore[test] recipe.

Addresses problems identified in pangeo-data/climpred#870

Changes here supersede existing Pull Requests:

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Refactoring
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
    • Dependencies have been updated.
    • suppress_warnings() was removed (not part of the User API).

How Has This Been Tested?

This has been tested locally using pytest and Python 3.11. GitHub Workflows have been slightly modified (and will continue to be modified in subsequent commits).

Checklist (while developing)

  • N/A

Pre-Merge Checklist (final steps)

  • I have rebased onto main or develop (wherever I am merging) and dealt with any conflicts.
  • I have squashed commits to a reasonable amount, and force-pushed the squashed commits.
  • Will squash commits on merge

Discussion

This Pull Request is required in order to support downstream libraries that rely on newer Python versions (Python 3.12/3.13) and modern scientific Python libraries (numpy, scipy, scikit-learn, xarray, etc.).

@Zeitsperre Zeitsperre changed the title Fix numpy125 Address DeprecationWarnings and suppress warnings for numpy 1.25+ May 7, 2025
@Zeitsperre
Copy link
Collaborator Author

Zeitsperre commented May 7, 2025

There are four (4) tests currently failing that imply changes in values:

FAILED xskillscore/tests/test_probabilistic.py::test_threshold_brier_score_api_and_inputs[True-DataArray-True] - AssertionError: Left and right DataArray objects are not identical
FAILED xskillscore/tests/test_probabilistic.py::test_threshold_brier_score_api_and_inputs[True-DataArray-False] - AssertionError: Left and right DataArray objects are not identical
FAILED xskillscore/tests/test_probabilistic.py::test_threshold_brier_score_api_and_inputs[False-DataArray-True] - AssertionError: Left and right DataArray objects are not identical
FAILED xskillscore/tests/test_probabilistic.py::test_threshold_brier_score_api_and_inputs[False-DataArray-False] - AssertionError: Left and right DataArray objects are not identical

In some cases, I believe the issue is a false positive:

E           AssertionError: Left and right DataArray objects are not identical
E           Differing values:
E           L
E               array(0.335185)
E           R
E               array(0.335185)

and in others there are some actual precision changes:

E           AssertionError: Left and right DataArray objects are not identical
E           Differing values:
E           L
E               np.float64(0.3351851851851852)
E           R
E               array(0.335185)

I'm not certain if these values are insignificant enough to be ignored.

Update: It's entirely possible that the differences may be due to the encoding of the array, in which case leveraging the numpy.testing.assert* functions should be used. Will confirm.

Update: I think the issue may have to do with deeper inspection provided by newer xarray versions: Differences in floating point mantissas might be enough to constitute two values not being identical. This doesn't seem to be the case for xarray==2024.7.0 (Python 3.9).

@Zeitsperre
Copy link
Collaborator Author

I noticed that the GitHub workflows weren't testing the proper Python versions (i.e. Python was being updated after being set within the workflows: 3.9/3.10/3.11 → 3.13). This has now also been fixed.

@Zeitsperre
Copy link
Collaborator Author

@raybellwaves @aaronspring @bradyrx This Pull Request is ready for review! Thanks!

@aaronspring aaronspring merged commit 491e741 into xarray-contrib:main May 10, 2025
18 checks passed
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.

2 participants