Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

between verbose, POSIXct support, RHS dot-alias, int64 support #3518

Merged
merged 31 commits into from May 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8047463
between incbounds, rm nocov, and test
jangorecki Apr 22, 2019
a153f9d
add verbose to between function, closes #3516
jangorecki Apr 22, 2019
48f3163
between support for POSIXct, closes #3519
jangorecki Apr 22, 2019
2fa1390
between support dot-list alias in RHS, closes #2315
jangorecki Apr 22, 2019
ccf0b42
fix missing check for is.call
jangorecki Apr 22, 2019
5f48c7e
Merge branch 'between-verbose' of https://github.com/Rdatatable/data.…
Apr 23, 2019
47b52e3
new functionality for parallel processing to apply to POSIX-as-string…
Apr 23, 2019
7841fef
Merge branch 'master' into between-verbose
mattdowle Apr 23, 2019
8fd7571
remove LHS=character restriction
Apr 24, 2019
1920c77
Merge branch 'between-verbose' of https://github.com/Rdatatable/data.…
Apr 24, 2019
64dec55
Merge branch 'master' into between-verbose
mattdowle Apr 25, 2019
088348f
merge master
mattdowle Apr 26, 2019
ed0cc29
GetVerbose() added at C level and used instead of needing to pass thr…
mattdowle Apr 26, 2019
f4a05c7
between posix from char more robust, remove unclass
jangorecki May 1, 2019
e25b0f4
more strict condition to redirect to Cbetween
jangorecki May 1, 2019
e18b095
Merge branch 'master' into between-verbose
jangorecki May 1, 2019
1259b66
between unit tests, minor reformat
jangorecki May 1, 2019
aa175aa
between int64 support and num-to-int coerce, #3517
jangorecki May 1, 2019
a60972b
update news file for more changes in between function
jangorecki May 1, 2019
102c6db
revert mistakenly altered branch of int32
jangorecki May 1, 2019
ab6754c
fixes and tests towards #3517, speed up isReallyReal
jangorecki May 1, 2019
6490517
remove debug print
jangorecki May 1, 2019
6ed0d69
typo fix
jangorecki May 1, 2019
12f1d2b
between int64 unit tests
jangorecki May 1, 2019
1548cce
minor fix to between int64 and more unit tests
jangorecki May 2, 2019
219f650
Merge branch 'master' into between-verbose
jangorecki May 2, 2019
aeee086
Merge branch 'master' into between-verbose
mattdowle May 2, 2019
851745e
between changes codecov
jangorecki May 3, 2019
3d0e4fe
Merge branch 'master' into between-verbose
mattdowle May 13, 2019
a0bd9b5
LLONG_MIN => INT64_MIN to isolate from possible LLONG variance, and m…
mattdowle May 13, 2019
89fa2cf
isReallyRealC => isRealReallyInt to simplify ||
mattdowle May 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 17 additions & 4 deletions R/between.R
Expand Up @@ -4,10 +4,23 @@ between <- function(x,lower,upper,incbounds=TRUE,verbose=getOption("datatable.ve
if (is.logical(lower)) lower = as.integer(lower) # typically NA (which is logical type)
if (is.logical(upper)) upper = as.integer(upper) # typically NA (which is logical type)
is_strictly_numeric <- function(x) is.numeric(x) && !inherits(x, "integer64")
jangorecki marked this conversation as resolved.
Show resolved Hide resolved
if (inherits(x, "POSIXct") && inherits(lower, "POSIXct") && inherits(upper, "POSIXct")) { #3519
x = unclass(x)
lower = unclass(lower)
upper = unclass(upper)
try_posix_cast <- function(x, tz) {
x_time = as.POSIXct(x, tz = tz)
if (is.na(x_time)) return(x)
jangorecki marked this conversation as resolved.
Show resolved Hide resolved
return(x_time)
}
if (inherits(x, "POSIXct")) {
# allow fast between on POSIX vs POSIX-as-string in some circumstances
# (biggest worry is hard-to-predict timezone mismatch)
if (!is.null(tz <- attr(x, 'tzone')) && (is.character(lower) || is.character(upper))) {
lower = try_posix_cast(lower, tz)
upper = try_posix_cast(upper, tz)
jangorecki marked this conversation as resolved.
Show resolved Hide resolved
}
if (inherits(lower, "POSIXct") && inherits(upper, "POSIXct")) { #3519
x = unclass(x)
lower = unclass(lower)
upper = unclass(upper)
}
}
if (is_strictly_numeric(x) && is_strictly_numeric(lower) && is_strictly_numeric(upper)) {
# faster parallelised version for int/double.
Expand Down
13 changes: 12 additions & 1 deletion inst/tests/tests.Rraw
Expand Up @@ -14071,9 +14071,20 @@ dn = as.POSIXct('2016-09-18 08:00:00')
up = as.POSIXct('2016-09-18 09:00:00')
test(2028.11, between(x, dn, up, verbose=TRUE), output="between parallel processing of double using closed bounds with recycling took")
test(2028.12, between(x, dn, up, incbounds=FALSE, verbose=TRUE), output="between parallel processing of double using open bounds with recycling took")

## also handling of string lower/upper bounds _only when x has a time zone_
jangorecki marked this conversation as resolved.
Show resolved Hide resolved
dn = as.character(dn)
up = as.character(up)
test(2028.13, between(x, dn, up, verbose = TRUE), output = 'optimised between not available')
attr(x, 'tzone') = 'UTC'
test(2028.14, between(x, dn, up, verbose = TRUE), output = 'between parallel processing of double')
### additional flexibility -- cast when one bound is already POSIXct
up = as.POSIXct(up)
test(2028.15, between(x, dn, up, verbose = TRUE), output = 'between parallel processing of double')

# `between` support `.` in RHS #2315
X = data.table(a = 1:5, b = 6:10, c = c(5:1))
test(2028.13, X[c %between% list(a, b)], X[c %between% .(a, b)])
test(2028.16, X[c %between% list(a, b)], X[c %between% .(a, b)])


###################################
Expand Down