Skip to content

Code review by Claude#528

Open
billdenney wants to merge 11 commits intomainfrom
code-review
Open

Code review by Claude#528
billdenney wants to merge 11 commits intomainfrom
code-review

Conversation

@billdenney
Copy link
Copy Markdown
Member

No description provided.

billdenney and others added 11 commits March 24, 2026 16:19
Adds design/ directory (excluded from R package build via .Rbuildignore)
containing architecture review, best practices audit, performance analysis,
code clarity notes, future work suggestions, and potential bugs identified
during a thorough review of the PKNCA codebase.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add comments to aucintegrate_log() and aumcintegrate_log() explaining
that equal concentrations cannot reach these functions because
choose_interval_method() only assigns "log" to strictly declining
intervals with no zero endpoints.

Mark bug #1 as resolved in the design review document.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add comment to interpolate_conc_log() explaining that zero/negative
concentrations cannot reach it because choose_interval_method() assigns
"zero" or "linear" to any interval with a zero endpoint.

Mark bug #2 as resolved in the design review document.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add an explicit check that idx_tlast has exactly one element after
which(time == tlast), placed after the all-zeros early return (where
tlast is NA). Raises an informative error if tlast is absent (e.g. due
to floating point inequality) or duplicated.

Add test using the classic 0.1 + 0.2 != 0.3 floating point case to
confirm the error fires correctly. Mark bug #3 resolved.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add comment explaining that when min.hl.points == 2 with only 2 points,
setting mask_best to all positive-lambda.z fits is intentional — the
existing sum(mask_best) > 1 block immediately below resolves ties by
selecting the fit with the most points.

Mark bug #4 as resolved in the design review document.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lve bug #5

Add comment explaining that tlast = tfirst + 1 is an intentional sentinel
used only for comparisons against ret$time, and is guaranteed to exceed all
observed time values since tfirst = max(ret$time).

Mark bug #5 as resolved in the design review document.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lve bugs #6 and #7

Replace all single | and & operators with || and && in scalar if()
conditions across 24 R source files for idiomatic short-circuit
evaluation. Vectorized uses of | and & (inside all(), any(), or
column-level mask construction) are unchanged.

Add comments to auc_integrate.R and cleaners.R documenting that
%in% 0 for BLQ detection is intentionally exact equality, since
BLQ values are cleaned to exactly 0 upstream and a tolerance cannot
be used without domain knowledge of what a "low" concentration means.

All 2292 tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
assert_conc_time() enforces unique time points before any interpolation
logic runs, so data\$time cannot contain duplicates at the call site in
interpolate.conc().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ntentional

stopifnot(!duplicated(x)) is idiomatic R: stopifnot() accepts a vector
and stops if any element is FALSE, so wrapping in any() is redundant.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ve issues 10-11

Issue 10: pk.calc.auc.inf.obs with lambda.z=NA propagates NA through
aucintegrate_inf (clast/NA) and correctly returns NA_real_. Test added
to tests/testthat/test-auc.R to confirm this behavior.

Issue 11: getGroups.PKNCAconc() lazy default argument is safe because
PKNCAconc objects are immutable in normal use. No code change needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All 11 items have been resolved (fixes applied, false positives
documented, or confirmed as intended behavior).

Co-Authored-By: Claude Sonnet 4.6 <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.

1 participant