Overview
Some unit tests in PyAutoFit run slower than necessary. This task profiles the test suite to identify the slowest tests and applies targeted optimizations to reduce total test runtime. Numerical correctness will be preserved — any changes to test values will be flagged for review. At the end, a reusable prompt will be produced so the same process can be applied to PyAutoGalaxy and PyAutoLens.
Plan
- Profile the full PyAutoFit test suite to identify the slowest tests
- Analyze bottlenecks (large arrays, unnecessary iterations, expensive fixtures)
- Apply targeted speedups without changing numerical reference values where possible
- Re-profile to validate improvements
- Produce a reusable prompt for applying the same process to PyAutoGalaxy and PyAutoLens
Detailed implementation plan
Affected Repositories
- PyAutoFit (primary and only repo for this task)
Work Classification
Library
Branch Survey
| Repository |
Current Branch |
Dirty? |
| PyAutoFit |
main_build |
clean |
Suggested branch: feature/unit-test-profiling
Implementation Steps
- Run
pytest test_autofit --durations=0 -q to collect timing data for all 1198 tests
- Identify the top 30+ slowest tests and read their source to understand bottlenecks
- Categorize slow tests: search iterations, large arrays, database I/O, fixture overhead
- For each category, apply safe optimizations (reduce sizes, scope fixtures, trim iterations)
- Flag any tests where numerical values would change — get user approval before modifying
- Re-run full suite to confirm all tests pass and measure improvement
- Write a reusable prompt file for PyAutoGalaxy and PyAutoLens
Key Files
test_autofit/ — 169 test files, 1198 tests
test_autofit/conftest.py — shared fixtures
test_autofit/non_linear/ — likely hotspot (search algorithm tests)
test_autofit/graphical/ — likely hotspot (EP/graphical model tests)
test_autofit/database/ — likely hotspot (database I/O tests)
Original Prompt
Click to expand starting prompt
This is a generic source code improvement that applies to all five PyAuto repos.
Basically, some unit test run slow, and this dev work aims to profile the unit tests
and speed them up as much as possible. We dont want to change numerical values on unit
tests where possile, hwoever I am also confident currently that the source code is stable
thus for the slower unit tesrts if there are safe changes we can make to speed them up, then we should do so,
but prompt me on the.
To begin, can we run this on PyAutoFit and I'll see how it goes and we
can then run it on the other repos.
Overview
Some unit tests in PyAutoFit run slower than necessary. This task profiles the test suite to identify the slowest tests and applies targeted optimizations to reduce total test runtime. Numerical correctness will be preserved — any changes to test values will be flagged for review. At the end, a reusable prompt will be produced so the same process can be applied to PyAutoGalaxy and PyAutoLens.
Plan
Detailed implementation plan
Affected Repositories
Work Classification
Library
Branch Survey
Suggested branch:
feature/unit-test-profilingImplementation Steps
pytest test_autofit --durations=0 -qto collect timing data for all 1198 testsKey Files
test_autofit/— 169 test files, 1198 teststest_autofit/conftest.py— shared fixturestest_autofit/non_linear/— likely hotspot (search algorithm tests)test_autofit/graphical/— likely hotspot (EP/graphical model tests)test_autofit/database/— likely hotspot (database I/O tests)Original Prompt
Click to expand starting prompt
This is a generic source code improvement that applies to all five PyAuto repos.
Basically, some unit test run slow, and this dev work aims to profile the unit tests
and speed them up as much as possible. We dont want to change numerical values on unit
tests where possile, hwoever I am also confident currently that the source code is stable
thus for the slower unit tesrts if there are safe changes we can make to speed them up, then we should do so,
but prompt me on the.
To begin, can we run this on PyAutoFit and I'll see how it goes and we
can then run it on the other repos.