Skip to content

fix: fail loud on non-logical half-life point columns and annotate unreportable half-life - #591

Open
billdenney wants to merge 2 commits into
mainfrom
583-halflife-exclusion-failloud
Open

fix: fail loud on non-logical half-life point columns and annotate unreportable half-life#591
billdenney wants to merge 2 commits into
mainfrom
583-halflife-exclusion-failloud

Conversation

@billdenney

Copy link
Copy Markdown
Member

Fixes #583.

(1) Non-logical exclude_half.life/include_half.life columns (e.g. "yes", which silently excluded nothing) now error with an informative message at both PKNCAconc() construction and again at pk.nca() time (catching post-construction mutation). (2) When no λz window survives the selection gate — including the case where a well-fitting λz ≤ 0 window anchors the adjusted-R² tolerance — the NA half-life now carries an exclusion reason via the standard attr(result, "exclude") mechanism, in both the log-linear and Tobit branches. Normal fits, the too-few-points path, and manual selection are unaffected.

Verification: full suite 2,717 pass / 0 fail (the 2 warnings are pre-existing on baseline); new tests pin the exact error messages, the new exclusion reasons (direct call and through pk.nca()), and clean exclude columns for healthy fits.

Note: a typo'd column name passed to these arguments still silently creates an all-NA "not in use" column — a separate silent path possibly worth its own issue.

🤖 Generated with Claude Code

billdenney and others added 2 commits August 9, 2026 11:48
…reportable half-life

Two silent-failure modes around half-life calculation are fixed for
issue 583:

- A non-logical exclude_half.life or include_half.life column (e.g.
  character "yes") was accepted silently and excluded or included
  nothing, because the per-point columns are matched against logical
  TRUE. PKNCAconc() now errors at construction, naming the column and
  stating that a logical (TRUE/FALSE/NA) column is required, and
  pk.nca() re-validates at calculation time in case the column was
  modified after construction.

- When no candidate lambda.z window survived point selection (e.g. a
  well-fitting window with lambda.z <= 0 anchoring the adjusted
  r-squared tolerance), pk.calc.half.life() returned NA with no
  exclusion reason. It now attaches "No valid terminal phase: ..."
  via the established attr(result, "exclude") mechanism for both the
  log-linear and Tobit methods, so the reason lands in the exclude
  column of pk.nca() results. Normal fits and the existing
  too-few-points messaging are unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Passing a column name to PKNCAconc(exclude_half.life=) or
PKNCAconc(include_half.life=) that does not exist in the data
silently created an all-NA logical column via setAttributeColumn()'s
default-value path, so a typo'd name deactivated the point selection
(an all-NA column is treated as "not in use") and passed the
is.logical() validation added earlier for issue 583.

PKNCAconc() now errors at construction using setAttributeColumn()'s
stop_if_default hook, naming the argument and the missing column.
The hook fires only on the missing-column path, so non-character
input keeps its existing "col_name must be a character scalar."
error and existing columns (including all-NA logical ones) are
unaffected.  Other setAttributeColumn() callers are unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

Silent failure modes: character exclude_half.life column excludes nothing; unreportable half-life leaves no exclusion reason

1 participant