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

use pytest skip for numpy2 test trapezoid #1988

Merged
merged 3 commits into from
May 15, 2024

Conversation

andrewgsavage
Copy link
Collaborator

  • Closes # (insert issue number)
  • Executed pre-commit run --all-files with no errors
  • The change is fully covered by automated unit tests
  • Documented in docs/ as appropriate
  • Added an entry to the CHANGES file

Copy link

codspeed-hq bot commented May 14, 2024

CodSpeed Performance Report

Merging #1988 will improve performances by ×17

Comparing andrewgsavage:numpy2_skip (9c4749c) with master (24dd237)

Summary

⚡ 1 improvements
✅ 436 untouched benchmarks

Benchmarks breakdown

Benchmark master andrewgsavage:numpy2_skip Change
test_build_by_mul[mid_array] 17.6 ms 1.1 ms ×17

Comment on lines 450 to 454
# NP2: Remove this when we only support np>=2.0
@pytest.mark.skipif(
np.lib.NumpyVersion(np.__version__) < "2.0.0b1",
reason="trapezoid added in numpy2",
)
Copy link
Contributor

Choose a reason for hiding this comment

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

we might need to make this a function. Something like

def requires_numpy_2(reason=None):
    if reason is None:
        reason = "requires numpy >= 2"
    return pytest.mark.skipif(np.lib.NumpyVersion(np.__version__) < "2.0.0b1", reason=reason)

...

@requires_numpy_2(reason="trapezoid added in numpy2")
def test_trapezoid(self):
    ...

could work. Otherwise it is possible to skip the entire test module if numpy is not available:

pytest.importorskip("numpy")

@andrewgsavage
Copy link
Collaborator Author

of course there was a helper for it all along...

@andrewgsavage andrewgsavage merged commit 8eb3e31 into hgrecco:master May 15, 2024
43 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