Catch typos in gear_params and species_params column names (#442)#455
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #442.
Problem
A mis-typed column name in a parameter data frame was silently ignored. The issue's example is
sel_funinstead ofsel_func:validGearParams()never finds asel_funccolumn, quietly defaults every gear toknife_edge, and builds a wrong model with no warning. (Thegear_paramsroxygen example itself usedsel_fun.)mizer already had misspelling detection, but it was three copy-pasted hard-coded lists matched with
intersect()— andsel_funwasn't on any of them.Change
check_for_misspellings()inR/helpers.Rfuzzy-matches each column name against the recognised parameter names using base Radist()(case-insensitive). A near miss — edit distance 1, or ≤2 for names of 6+ characters — triggers a warning suggesting the intended name.check_gear_params()(R/setFishing.R) — the recognised set is the core columns, the built-in selectivity parameters, plus (viaformals()) the arguments of anysel_funcactually referenced, so custom selectivity parameters are recognised too.species_paramsvalidation paths (R/species_params.R), backed by a hand-assembled list of recognised species-parameter columns.catch,Rmax) that lie beyond the fuzzy threshold.gear_paramsroxygen example.Verification
`sel_fun` (did you mean `sel_func`?).NS_species_params,NS_species_params_gears, and thegear_params/species_paramsofNS_params.sel_fun/w_maxxtypo 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