lnccbrown / lnccbrown/HSSM

tests: test_plotting_cartoon re-samples predictives in every parametrization — ship predictive groups in the cartoon fixtures

Open
#1,080 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

refactor
Dominant language
Python
Stars
124
Forks
24
Avg merge
19h 32m
Merged PRs (30d)
60

Description

## Problem

`tests/test_plotting_cartoon.py` costs 9.9 min (run 29419740259, py3.12). The cartoon fixtures `idata_cavanagh_cartoon.nc` and `test_idata_race.nc` contain **only** posterior/sample_stats/observed_data — no predictive groups — so `_use_traces_or_sample` (`src/hssm/plotting/utils.py:519-535`) re-samples posterior/prior predictive **inside every one of the ~30 non-error parametrizations**; for the `race_no_bias_angle_4` LAN model that is ~50 s per test. The assertions only check facet structure (row/col names, list lengths per group) — pure pandas/matplotlib logic independent of the sampled values.

## Plan

1. Regenerate the two `.nc` fixtures **once** to include small predictive groups (e.g. 10-draw `posterior_predictive` + a small prior/prior_predictive), so no test ever samples. This also speeds any future consumer of these fixtures.
2. De-duplicate the prior/posterior mirror rows in the two grids (`test_plotting_cartoon.py:13-43` 2-choice, `:118-146` 3-choice): every row is currently duplicated across `predictive_group`; keep each group covered once, not per-row.
3. The two `(False, False)` ValueError rows per grid raise before sampling — they don't need the expensive fixture at all.
4. **Trap:** do not simply module-scope `cav_model_cartoon` — it depends on the function-scoped `cavanagh_test` fixture (`tests/conftest.py:193-196`, `219-249`), which is a hard pytest `ScopeMismatch`. If scoping is used instead of (or in addition to) fixture regeneration, raise `cavanagh_test`'s scope in the same change and have consumers take copies.

## Acceptance

- File total from ~10 min to ≤ ~3 min.
- Both predictive-group code paths (posterior_predictive and prior_predictive) still exercised at least once per model type.
- Regenerated fixtures committed with the script used to produce them (reproducibility).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/test_plotting_cartoon.py, the cartoon .nc fixtures, and _use_traces_or_sample in src/hssm/plotting/utils.py:519-535; inspect fixture definitions in tests/conftest.py:193-196 and 219-249 before changing scope. Regenerate both fixtures with predictive groups, de-duplicate the parametrization grids, and run the plotting tests. Done means both predictive paths remain covered, fixtures have a reproducible generation script, and the file completes in no more than three minutes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance, testing-qa
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.