Skip to content

Fix pk.nca() error on unsorted concentration-time data (#568)#569

Merged
billdenney merged 1 commit into
mainfrom
claude/pknca-unsorted-group-data-b8014d
Jul 9, 2026
Merged

Fix pk.nca() error on unsorted concentration-time data (#568)#569
billdenney merged 1 commit into
mainfrom
claude/pknca-unsorted-group-data-b8014d

Conversation

@billdenney

Copy link
Copy Markdown
Member

Group-level concentration data (passed as conc.group/time.group to
parameters such as aucint*) was passed to the calculation routines in
its original row order. Those parameters interpolate/extrapolate over the
full group via interp.extrap.conc(), which asserts that time is sorted,
so unsorted input rows caused a "Must be sorted" error.

Fix: sort data_conc by time at the top of pk.nca.intervals(). The
interval-level data were already sorted per interval, so only the
group-level path was affected.

Adds a regression test (unsorted input matches pre-sorted results across
aucint*, cmax, half.life) and a NEWS.md entry.

Fixes #568.

Group-level concentration data (passed as conc.group/time.group to
parameters such as aucint*) was passed to the calculation routines in
its original row order. Parameters that interpolate/extrapolate over the
full group via interp.extrap.conc() assert that time is sorted, so
unsorted input rows caused a "Must be sorted" error.

Sort data_conc by time at the top of pk.nca.intervals() so the
group-level vectors are time-ordered. The interval-level data were
already sorted per interval, so only the group-level path was affected.

Adds a regression test verifying that unsorted input produces the same
results as pre-sorted input across aucint*, cmax, and half.life, and a
NEWS.md entry.

Fixes the issue reported in humanpred/pknca issue 568.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@billdenney billdenney merged commit eff7925 into main Jul 9, 2026
7 checks passed
@billdenney billdenney deleted the claude/pknca-unsorted-group-data-b8014d branch July 9, 2026 01:42
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.

Unsorted group time causes error with aucint* parameters

1 participant