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

Replacing np.allclose #382

Merged
merged 16 commits into from
Feb 28, 2025
Merged

Conversation

davidorme
Copy link
Collaborator

@davidorme davidorme commented Jan 6, 2025

Description

This PR is to replace the use of assert np.allclose in testing with np.testing.assert_allclose. The testing version checks that shapes are equal, where np.allclose allows broadcasting before testing values (see #380).

  • Replace calls in test_*.py files and import np.testing.assert_allclose.
  • "Fix" issues where previously passing tests now fail due to differences in default permitted tolerances. This PR does not change any of the package code, so no calculations differ: it is simply differences in the permitted tolerance and we accepted the values before.
  • Look at the new fails where the shape is not as expected and np.allclose let it pass.

Important

  • All of the shape issues turn out to have been sloppy specification of the expected values. The code was working as intended but the shapes of the test values were incorrect.
  • I've rebased this onto the branch for [META] Release 2.0.0 #383 rather than develop - this isn't something that is a bug exactly in 1.0.0.

Fixes #380 (issue)

Type of change

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist

  • Make sure you've run the pre-commit checks: $ pre-commit run -a
  • All tests pass: $ poetry run pytest

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@davidorme davidorme changed the base branch from develop to 383-meta-release-200 February 27, 2025 16:20
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (383-meta-release-200@f57760f). Learn more about missing BASE report.

Additional details and impacted files
@@                   Coverage Diff                   @@
##             383-meta-release-200     #382   +/-   ##
=======================================================
  Coverage                        ?   96.72%           
=======================================================
  Files                           ?       35           
  Lines                           ?     2660           
  Branches                        ?        0           
=======================================================
  Hits                            ?     2573           
  Misses                          ?       87           
  Partials                        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@davidorme davidorme marked this pull request as ready for review February 28, 2025 11:31
Copy link
Collaborator

@MarionBWeinzierl MarionBWeinzierl left a comment

Choose a reason for hiding this comment

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

Seems fine, just checking about one of the tolerances

@davidorme davidorme merged commit bc93572 into 383-meta-release-200 Feb 28, 2025
16 checks passed
@davidorme davidorme deleted the 380-replace-npallclose branch February 28, 2025 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Replace usage of np.allclose in testing with assert_allclose
3 participants