tests: test_sample_posterior_predictive — 4 cases × ~128 s predict over all 500 posterior draws; use a thinned fixture variant
- Dominant language
- Python
- Stars
- 124
- Forks
- 24
- Avg merge
- 19h 32m
- Merged PRs (30d)
- 60
Description
## Problem
`tests/test_sample_posterior_predictive.py` costs 10.0 min, of which 4 of the 16 grid cases account for 514 s (~128 s each, measured in run 29419740259, py3.12): the `draws=None` and `draws=np.arange(500)` rows (× inplace) run a full 500-draw bambi predict over the ~3000-row cavanagh posterior, with `safe_mode=True` additionally chunking into 50 sequential batches of 10 (`src/hssm/base.py:1085-1091`). The assertions only check `posterior_predictive.draw.size` and inplace-vs-return semantics — no values. (Model rebuild per case is cheap: the 1-draw combos take ~2 s.)
## Plan
- Add a thinned fixture **variant** (e.g. `cav_dt_thin`) that applies `isel(draw=slice(0, 20))` to the posterior (all groups consistently), and point the 500-draw rows at it: `draws=None` on the thinned posterior and `np.arange(20)` replace the 500-draw cases; expected sizes adapt trivially.
- **Do not regenerate or thin the shared `tests/fixtures/cavanagh_idata.nc`** — blast radius: 32 references in `tests/test_plotting.py`; `tests/test_utils.py:278-279` reads BOTH its posterior and posterior_predictive groups; `test_sample_posterior_predictive.py:62-63` hardcodes `size = 500`.
- Cheaper complement: delete 2 of the 4 500-draw rows — the `safe_mode × inplace` matrix is already fully covered at `draws=1` and `draws=50`.
## Acceptance
- File total from ~10 min to ≤ ~2 min.
- `draws=None` (full-posterior) semantics still covered; `safe_mode` chunking path still exercised.
- No other test file touched.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Contributor guide
Research direction
Start in tests/test_sample_posterior_predictive.py, then inspect the fixture setup and src/hssm/base.py:1085-1091 to understand the safe_mode chunking path. Add the thinned fixture variant and use it for the relevant rows without changing the shared cavanagh fixture or other test files. Done means the full-posterior and chunking semantics remain covered, with the file completing in ≤2 minutes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- performance, testing-qa
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100