Skip to content

Catch typos in gear_params and species_params column names (#442)#455

Merged
gustavdelius merged 2 commits into
masterfrom
catch-gear-params-typos
Jul 17, 2026
Merged

Catch typos in gear_params and species_params column names (#442)#455
gustavdelius merged 2 commits into
masterfrom
catch-gear-params-typos

Conversation

@gustavdelius

Copy link
Copy Markdown
Member

Fixes #442.

Problem

A mis-typed column name in a parameter data frame was silently ignored. The issue's example is sel_fun instead of sel_func: validGearParams() never finds a sel_func column, quietly defaults every gear to knife_edge, and builds a wrong model with no warning. (The gear_params roxygen example itself used sel_fun.)

mizer already had misspelling detection, but it was three copy-pasted hard-coded lists matched with intersect() — and sel_fun wasn't on any of them.

Change

  • New internal helper check_for_misspellings() in R/helpers.R fuzzy-matches each column name against the recognised parameter names using base R adist() (case-insensitive). A near miss — edit distance 1, or ≤2 for names of 6+ characters — triggers a warning suggesting the intended name.
  • Warn only, never rename. Columns are left untouched so legitimate custom columns are safe.
  • Wired into check_gear_params() (R/setFishing.R) — the recognised set is the core columns, the built-in selectivity parameters, plus (via formals()) the arguments of any sel_func actually referenced, so custom selectivity parameters are recognised too.
  • Wired into both species_params validation paths (R/species_params.R), backed by a hand-assembled list of recognised species-parameter columns.
  • The curated abbreviation lists are retained for familiar mistakes (e.g. catch, Rmax) that lie beyond the fuzzy threshold.
  • Fixed the gear_params roxygen example.

Verification

  • The issue's exact case now warns: `sel_fun` (did you mean `sel_func`?).
  • No false positives: zero misspelling warnings on NS_species_params, NS_species_params_gears, and the gear_params/species_params of NS_params.
  • Full test suite: 790 contexts, 0 failures, 0 errors. Added tests cover the sel_fun/w_maxx typo cases and no-warning cases for genuine custom columns.

Note for maintainers

The recognised species-parameter list in known_species_params_columns() is hand-assembled. New standard parameters should be added there too, otherwise a legitimate use could draw a spurious "did you mean" warning.

🤖 Generated with Claude Code

https://claude.ai/code/session_01T98LXny6oRNBMy9kHubpo4

gustavdelius and others added 2 commits July 15, 2026 13:32
A mis-typed column name such as `sel_fun` instead of `sel_func` was
silently ignored: validGearParams() would not find a `sel_func` column
and quietly default every gear to knife_edge, building a wrong model
with no warning.

Replace the three hard-coded misspelling lists (one for gear_params, two
for species_params) with a shared helper check_for_misspellings() that
fuzzy-matches each column name against the recognised parameter names
using base R adist(). A near miss now triggers a warning suggesting the
intended name. Columns are only flagged, never renamed, so legitimate
custom columns are left untouched. The curated abbreviation lists are
retained for familiar mistakes that lie beyond the fuzzy threshold.

Also fix the gear_params roxygen example, which itself used `sel_fun`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T98LXny6oRNBMy9kHubpo4
@gustavdelius
gustavdelius merged commit 9348464 into master Jul 17, 2026
@gustavdelius
gustavdelius deleted the catch-gear-params-typos branch July 17, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Catch typos in gear_params column names

1 participant