fix(vectors): clear error for an out-of-range layer in normalize_alpha / dose - #21
Conversation
…_alpha A layer missing from the steering vector raised a bare KeyError with no hint of which layers exist. Guard in normalize_alpha (dose() reaches it through the same path) and name both the bad layer and the available ones. Fixes bamdadd#20
|
Thanks for this — the change itself is good. The out-of-range layer now raises a clear, typed The only thing standing between this and a merge is formatting: CI's uv run ruff format .
git commit -am "style: ruff format"
git pushPush that and the checks should go green; I'll merge as soon as they do. Ping me if anything's unclear. If steerbench is useful to you, a star helps others find it and Watch will keep you posted — glad to have you contributing. |
|
Applied the one formatting step for you ( Two clean contributions in a row now — really glad to have you here. If steerbench is useful to you, a star helps others find it and Watch keeps you posted on new issues; would love more contributions whenever you're up for it. |
An invalid --effect-col reached the user as an uncaught ValueError from mid-parse in report.py, exiting 1 with a traceback. The message content was right, but the delivery was inconsistent with every other CLI input error -- the missing-CSV guards a few lines above, and bamdadd#21/bamdadd#22/bamdadd#23, all go through parser.error() for a clean one-line message and exit 2. Pre-validate the column against both sweep headers instead, next to the existing existence checks. report.sweep_columns() splits the header read out of _read_sweep_rows so the check does not duplicate the parse; the in-parse guard stays as the library-level backstop for direct load_dose_curve callers. Checking both CSVs matters because the column is read from each: a name only one sweep carries now names which file is short.
Problem
Requesting a layer that is not in the vector raised a bare
KeyError: 999, which doesn't tell the user which layers exist.Fix
Guard at the top of
normalize_alpha(whichdose()also goes through):Tests
normalize_alpha(vec, layer=999, ...)anddose(vec, layer=999, ...)both raise the newValueErrornaming the layer and listing available layers (2-layer vector)python -m pytest tests/test_vectors.pypasses.Fixes #20