Repository navigation
Compare element-wise when value is a vector in chk_lte(), chk_lt(), chk_gte() and chk_gt() - #324
Merged
Merged
Conversation
…hk_gte() and chk_gt() Closes #323. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #323
chk_lte(),chk_lt(),chk_gte()andchk_gt()(and theirvld_counterparts) now accept avaluethat is either:x: values are compared element-wise and pairs where either value is missing are ignored. The error message gives the failing positions, e.g.`x` must have values less than or equal to the corresponding values of `value`, not at positions 1 and 2.Any other length of
valuenow errors with`value` must be a scalar or the same length as `x`.instead of being silently recycled.Behaviour changes
valuewhose length is not 1 orlength(x)now errors instead of being recycled.valuewas documented as a scalar, so this only affects undocumented use. I haven't run reverse-dependency checks.valuebehaves exactly as before, including a missing scalarvalue, for whichvld_*()still returnsNA.Verification
tests/testthat/test-chk-range.Rcover vector values for all four checkers, missing values on either side, length mismatches, POSIXct dates and error messages.R CMD check: 0 errors, 0 warnings, 0 notes.Performance
Per-call times for
vld_lte(), old vs new (chk_lte()is similar). Each is the best of 5 timed loops.x, scalarvaluexof length 1e3, scalarvaluexof length 1e6, scalarvaluexof length 1e3, vectorvaluexof length 1e6, vectorvaluexof length 1e6 (10% NA), vectorvalueA scalar
valuecosts about 0.8 µs more per call, from the extra internal function call. When neither vector has missing values, the vectors are compared directly, which is faster than before because no subsetting is needed. Missing values in either vector are handled element-wise.NEWS.md is left to fledge.
🤖 Generated with Claude Code