Skip to content

fix: update.PKNCAresults handles ordered-factor groups and stops warning about unchanged groups - #589

Open
billdenney wants to merge 1 commit into
mainfrom
581-update-ordered-factor
Open

fix: update.PKNCAresults handles ordered-factor groups and stops warning about unchanged groups#589
billdenney wants to merge 1 commit into
mainfrom
581-update-ordered-factor

Conversation

@billdenney

Copy link
Copy Markdown
Member

Fixes #581.

Two fixes: (1) all update-machinery joins now match group keys by value (factor keys coerced to character on join copies only), fixing the vctrs incompatible-ordered-factor error while preserving classes, ordered-ness, and levels in returned data; (2) auto-generated per-group intervals are now filtered to the changed groups like conc and dose already were, so unchanged groups are neither recomputed nor warned about. Plus a guard: an update where no group's data changed returns the existing results with the new data attached (message) instead of erroring on an empty recalculation.

Verification: ordered-factor Theoph update is error-free, warning-free, and expect_identical to a full recomputation; unchanged-subject rows byte-identical to originals; character-subject regression guard; the new assertions fail on unfixed main exactly as designed. Full suite: 2,715 pass / 0 fail. The v01 vignette sentence explaining the old warnings is updated (its update example now runs warning-free).

🤖 Generated with Claude Code

…ing about unchanged groups

Fixes two defects in update.PKNCAresults() (issue 581):

- Joins between the old and new data errored with "incompatible types"
  when group columns were factors whose levels differed (e.g. the
  ordered-factor Subject in datasets::Theoph after re-leveling), because
  dplyr/vctrs cannot combine ordered factors with different levels. All
  joins in the update machinery (changed-group detection, changed-row
  filtering, and dropping recalculated groups from the old results) now
  match group columns by value, coercing factor join keys to character
  only for matching; the returned data keep their original classes and
  factor levels.

- Updating one group's data warned "No concentration data" for every
  unchanged group because the intervals were left unfiltered while the
  concentration and dose data were filtered to the changed groups. The
  intervals are now filtered to the changed groups symmetrically, so
  unchanged groups are not calculated and produce no warnings. The set
  of recalculated groups and the merged result are unchanged.

Also return early (keeping existing results) when the new data differ
only in ways that change no group's data, e.g. group-block reordering;
previously this crashed in getGroups() on an empty recalculation.

The v01 vignette sentence explaining the per-subject warnings is
updated because the warnings no longer occur.

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.

update.PKNCAresults errors on ordered-factor group columns and emits per-subject warnings for unchanged groups

1 participant