Repository navigation
move argument validation from [ - #7937
ben-schwen wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## brk/a5_cedta_helper #7937 +/- ##
======================================================
Coverage ? 99.09%
======================================================
Files ? 88
Lines ? 17428
Branches ? 0
======================================================
Hits ? 17270
Misses ? 158
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4c8c97a to
7c6b369
Compare
7c6b369 to
4b099e6
Compare
(Plot image upload to picrd.com failed; download the artifact below to view plots) Generated via commit f7e2b2d Download link for the artifact containing the test results: ↓ atime-results.zip
|
No behaviour change.
4b099e6 to
f7e2b2d
Compare
| nomatch=NA # convert NA_character_ to NA-logical, PR#5216 | ||
| } | ||
| if (!is.logical(which) || length(which)>1L) stopf("which= must be a logical vector length 1. Either FALSE, TRUE or NA.") | ||
| if ((isTRUE(which)||is.na(which)) && !missing_j) stopf("which==%s (meaning return row numbers) but j is also supplied. Either you need row numbers or the result of j, but only one type of result can be returned.", which) |
There was a problem hiding this comment.
similarly to #7936, I wonder about just re-computing missing(j) here. On this first branch, it's clearly the unusual code path; on the latter one, it's more "typical". Also, this helper has a ton of arguments anyway, so one extra one is not so bad.
| if (is.character(roll)) { | ||
| if (roll!="nearest") stopf("roll is '%s' (type character). Only valid character value is 'nearest'.", roll) | ||
| } else { | ||
| roll = if (isTRUE(roll)) +Inf else as.double(roll) | ||
| } |
There was a problem hiding this comment.
Possibly nicer?
| if (is.character(roll)) { | |
| if (roll!="nearest") stopf("roll is '%s' (type character). Only valid character value is 'nearest'.", roll) | |
| } else { | |
| roll = if (isTRUE(roll)) +Inf else as.double(roll) | |
| } | |
| if (!is.character(roll)) { | |
| roll = if (isTRUE(roll)) +Inf else as.double(roll) | |
| } else if (roll != "nearest") { | |
| stopf("roll is '%s' (type character). Only valid character value is 'nearest'.", roll) | |
| } |
Or even
| if (is.character(roll)) { | |
| if (roll!="nearest") stopf("roll is '%s' (type character). Only valid character value is 'nearest'.", roll) | |
| } else { | |
| roll = if (isTRUE(roll)) +Inf else as.double(roll) | |
| } | |
| if (is.numeric(roll)) { | |
| roll = as.double(roll) | |
| } else if (isTRUE(roll)) { | |
| roll = +Inf | |
| } else if (roll != "nearest") { | |
| stopf("roll is '%s' (type character). Only valid character value is 'nearest'.", roll) | |
| } |
With the caveat that the error branch now also picks up non-numeric roll that was previously accepted and coerced (e.g. roll = 1+1i)
Towards #852