Skip to content

move argument validation from [ - #7937

Open
ben-schwen wants to merge 1 commit into
brk/a5_cedta_helperfrom
brk/a6_check_args
Open

ben-schwen wants to merge 1 commit into
brk/a5_cedta_helperfrom
brk/a6_check_args

Conversation

@ben-schwen

Copy link
Copy Markdown
Member

Towards #852

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (brk/a5_cedta_helper@301e163). Learn more about missing BASE report.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
  • HEAD=brk/a6_check_args slower P<0.001 for fwrite refactored in #6393
  • HEAD=brk/a6_check_args faster P<0.001 for DT[by] max regression fixed in #7480
  • HEAD=brk/a6_check_args faster P<0.001 for DT[by,verbose=TRUE] improved in #6296

(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

Task Duration
R setup and installing dependencies 2 minutes and 35 seconds
Installing different package versions 13 minutes and 29 seconds
Running and plotting the test cases 5 minutes and 48 seconds

No behaviour change.
Comment thread R/data.table.R
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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread R/data.table.R
Comment on lines +547 to +551
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)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly nicer?

Suggested change
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

Suggested change
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)

This branch has not been deployed

No deployments
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.

2 participants