Skip to content

TST: add a lot of missing slow markers - #31420

Merged
seberg merged 2 commits into
numpy:mainfrom
rgommers:tst-mark-slow
May 13, 2026
Merged

seberg merged 2 commits into
numpy:mainfrom
rgommers:tst-mark-slow

Conversation

@rgommers

Copy link
Copy Markdown
Member

As discussed in gh-31419, the goal is to mark tests with a duration above 0.5-1 sec. on commonly used CPUs (say x86-64 CPU of a few years old) as slow unless there's a good reason to keep it in the default set that gets executed by numpy.test() rather than numpy.test('full').

Slowest tests are compile tests for cython and f2py, tests for reference cycles and the like, multi-threaded tests, custom memory allocators, and highly parametrized tests that are relatively slow (often dealing with object arrays or other inherently slower features).

Most of the changes are for f2py; almost all compile tests were in the default set - which doesn't really make sense.

With this change, we move about 700 out of 47,000 tests to the 'full' mode, resulting in a speedup of the default test() invocation of roughly 50%. Remaining slowest tests recorded in 31419#comment.

Closes gh-31419

AI Disclosure

I did the first several iterations by hand, then asked Claude Code to apply the rest of the markers based on the output of spin test . -- --durations=50.

As discussed in issue 31419, the goal is to mark tests with a duration
above 0.5-1 sec. on commonly used CPUs (say x86-64 CPU of a few years old)
as `slow` unless there's a good reason to keep it in the default
set that gets executed by `numpy.test()` rather than `numpy.test('full')`.

Slowest tests are compile tests for `cython` and `f2py`, tests for reference
cycles and the like, multi-threaded tests, custom memory allocators,
and highly parametrized tests that are relatively slow (often dealing with
object arrays or other inherently slower features).

With this change, we move about 700 out of 47,000 tests to the 'full' mode,
resulting in a speedup of the default test() invocation of roughly 50%.

Closes numpygh-31419

@seberg seberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, LGTM. We probably also have some highly parametrized tests that could be marked slow (IIRC --durations reports individual tests, if you have a gigantic parametrization it doesn't notice).

These look good though, most are compilation tests and it looks like the f2py changes are just that the existing pattern wasn't used consistently anyway.
(And I agree to keep the cython ones, they compile, but not for each individual test in practice.)

@seberg

seberg commented May 13, 2026

Copy link
Copy Markdown
Member

Hmmmm, one small caveat is that I think with this we don't have a single f2py test that actually runs on any platform, so e.g. the riscv job won't try to compile at all.
Not sure if there is an obvious test that we could exempt here?

(I am OK with it as is, just realized that this is a bit of a downside, of applying to almost all slow tests, as compilation tests are always slow.)

@rgommers

Copy link
Copy Markdown
Member Author

Let me check - I intended to leave 3 compile tests for f2py, if none are running then something went wrong.

@seberg

seberg commented May 13, 2026

Copy link
Copy Markdown
Member

I didn't check super careful, but it seemed to me there were 2 skipped not marked and one that was linux only or so.

Mark the three f2py test classes that we intentionally leave unmarked
as compile-path coverage for the default `pixi run test` invocation, so
a future contributor doesn't add `slow` to them.

[ci skip]
@rgommers

Copy link
Copy Markdown
Member Author

Good catch, something got lost. I pushed a new commit with the fix, and also adding a comment to each of the three tests that they shouldn't be marked slow. They take ~2sec. per test (on M5 Macbook):

2.05s setup    build-install/usr/lib/python3.14/site-packages/numpy/f2py/tests/test_size.py::TestSizeSumExample::test_all
2.03s setup    build-install/usr/lib/python3.14/site-packages/numpy/f2py/tests/test_quoted_character.py::TestQuotedCharacter::test_quoted_character
2.02s setup    build-install/usr/lib/python3.14/site-packages/numpy/f2py/tests/test_assumed_shape.py::TestAssumedShapeSumExample::test_all

Three separate tests feels like plenty, could micro-optimize but should be about right.

(can be squash-merged now I think, the second commit message isn't very interesting)

@seberg
seberg merged commit fa50a8c into numpy:main May 13, 2026
@rgommers
rgommers deleted the tst-mark-slow branch May 13, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Too many slow tests in 'fast' (default) test suite run

2 participants