Skip to content

Commit dff3ee0

Browse files
authored
Merge branch 'master' into i64remapfix
2 parents b58698e + b07be17 commit dff3ee0

File tree

7 files changed

+81
-53
lines changed

7 files changed

+81
-53
lines changed

.github/workflows/performance-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
2121
repo_token: ${{ secrets.GITHUB_TOKEN }}
2222
steps:
23-
- uses: Anirban166/[email protected].1
23+
- uses: Anirban166/[email protected].2

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
5. `as.data.table()` is slightly more efficient at converting arrays to data.tables, [#7019](https://github.com/Rdatatable/data.table/pull/7019). Thanks @eliocamp.
1818

19+
6. `between()` gains the argument `ignore_tzone=FALSE`. Normally, a difference in time zone between `lower` and `upper` will produce an error, and a difference in time zone between `x` and either of the others will produce a message. Setting `ignore_tzone=TRUE` bypasses the checks, allowing both comparisons to proceed without error or message about time zones.
20+
1921
### BUG FIXES
2022

2123
1. Custom binary operators from the `lubridate` package now work with objects of class `IDate` as with a `Date` subclass, [#6839](https://github.com/Rdatatable/data.table/issues/6839). Thanks @emallickhossain for the report and @aitap for the fix.
@@ -34,7 +36,9 @@
3436

3537
8. `fread()` no longer warns on certain systems on R 4.5.0+ where the file owner can't be resolved, [#6918](https://github.com/Rdatatable/data.table/issues/6918). Thanks @ProfFancyPants for the report and PR.
3638

37-
9. Out of sample type bumps now respect `integer64=` selection, [#7032](https://github.com/Rdatatable/data.table/pull/7032)
39+
9. Joins to extended data.frames, e.g. `x[i, col := x.col1 + i.col2]` where `i` is a `tbl`, can use the `x.` and `i.` prefix forms, [#6998](https://github.com/Rdatatable/data.table/issues/6998). Thanks @MichaelChirico for the bug and PR.
40+
41+
10. Out of sample type bumps now respect `integer64=` selection, [#7032](https://github.com/Rdatatable/data.table/pull/7032)
3842

3943
### NOTES
4044

R/between.R

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# is x[i] in between lower[i] and upper[i] ?
2-
between = function(x, lower, upper, incbounds=TRUE, NAbounds=TRUE, check=FALSE) {
2+
between = function(x, lower, upper, incbounds=TRUE, NAbounds=TRUE, check=FALSE, ignore_tzone=FALSE) {
33
if (is.logical(x)) stopf("between has been passed an argument x of type logical")
44
if (is.logical(lower)) lower = as.integer(lower) # typically NA (which is logical type)
55
if (is.logical(upper)) upper = as.integer(upper) # typically NA (which is logical type)
@@ -16,15 +16,12 @@ between = function(x, lower, upper, incbounds=TRUE, NAbounds=TRUE, check=FALSE)
1616
stopifnot(is.px(x), is.px(lower), is.px(upper)) # nocov # internal
1717
}
1818
# POSIX check timezone match
19-
if (is.px(x) && is.px(lower) && is.px(upper)) {
20-
tzs = sapply(list(x,lower,upper), function(x) {
21-
attr(x, "tzone", exact=TRUE) %||% ""
22-
})
19+
if (!ignore_tzone && is.px(x) && is.px(lower) && is.px(upper)) {
20+
tzs = vapply_1c(list(x, lower, upper), function(x) attr(x, "tzone", exact=TRUE) %||% "")
2321
# lower/upper should be more tightly linked than x/lower, so error
2422
# if the former don't match but only inform if they latter don't
2523
if (tzs[2L]!=tzs[3L]) {
2624
stopf("'between' lower= and upper= are both POSIXct but have different tzone attributes: %s. Please align their time zones.", brackify(tzs[2:3], quote=TRUE))
27-
# otherwise the check in between.c that lower<=upper can (correctly) fail for this reason
2825
}
2926
if (tzs[1L]!=tzs[2L]) {
3027
messagef("'between' arguments are all POSIXct but have mismatched tzone attributes: %s. The UTC times will be compared.", brackify(tzs, quote=TRUE))

R/data.table.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,10 +677,12 @@ replace_dot_alias = function(e) {
677677
}
678678
ansvals = chmatch(ansvars, nx)
679679
} else {
680-
if (is.data.table(i)) {
680+
if (is.data.frame(i)) {
681681
idotprefix = paste0("i.", names_i)
682682
xdotprefix = paste0("x.", names_x)
683-
} else idotprefix = xdotprefix = character(0L)
683+
} else {
684+
idotprefix = xdotprefix = character(0L)
685+
}
684686

685687
# j was substituted before dealing with i so that := can set allow.cartesian=FALSE (#800) (used above in i logic)
686688
if (is.null(jsub)) return(NULL)

inst/tests/tests.Rraw

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21133,3 +21133,27 @@ test(2315.1, tail(DT[order(i), i], 2L), 1:2)
2113321133
# wider range of numbers needed for further coverage
2113421134
DT[1L, i := 1000L]
2113521135
test(2315.2, tail(DT[order(i), i], 2L), c(1L, 1000L))
21136+
21137+
# issue #6898, test that tzone behavior changes with ignore_tzone=TRUE
21138+
tms = list(.POSIXct(1), .POSIXct(1.0, "UTC"))
21139+
test(2316.1, between(tms[[1]], tms[[1L]], tms[[2L]]), error = "different tzone attributes")
21140+
test(2316.2, between(tms[[1]], tms[[1L]], tms[[2L]], ignore_tzone=TRUE))
21141+
test(2316.3, between(tms[[1]], tms[[2L]], tms[[2L]]), message = "mismatched tzone attributes")
21142+
test(2316.4, between(tms[[1]], tms[[2L]], tms[[2L]], ignore_tzone=TRUE))
21143+
21144+
# tbl in i still allows 'i.' prefix reference for update join, #6998
21145+
DT1 = data.table(a=1, b=2)
21146+
DT2 = data.table(a=1, c=3)
21147+
DF1 = data.frame(a=1, d=4)
21148+
DF2 = data.frame(a=1, e=5)
21149+
class(DF2) = c("tbl_df", "tbl", "data.frame")
21150+
21151+
test(2317.1, DT1[DT2, on='a', c := i.c]$c, 3)
21152+
test(2317.2, DT1[DT2, on='a', c2 := x.a + i.c]$c2, 4)
21153+
test(2317.3, DT1[DT2, on='a', .(c = x.a + i.c)]$c, 4)
21154+
test(2317.4, DT1[DF1, on='a', d := i.d]$d, 4)
21155+
test(2317.5, DT1[DF1, on='a', d2 := x.a + i.d]$d2, 5)
21156+
test(2317.6, DT1[DF1, on='a', .(d = x.a + i.d)]$d, 5)
21157+
test(2317.7, DT1[DF2, on='a', e := i.e]$e, 5)
21158+
test(2317.8, DT1[DF2, on='a', e2 := x.a + i.e]$e2, 6)
21159+
test(2317.9, DT1[DF2, on='a', .(e = x.a + i.e)]$e, 6)

man/between.Rd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This can be changed by setting \code{NAbounds} to \code{NA}.
1616
the intervals provided in \code{lower,upper}.
1717
}
1818
\usage{
19-
between(x, lower, upper, incbounds=TRUE, NAbounds=TRUE, check=FALSE)
19+
between(x, lower, upper, incbounds=TRUE, NAbounds=TRUE, check=FALSE, ignore_tzone=FALSE)
2020
x \%between\% y
2121

2222
inrange(x, lower, upper, incbounds=TRUE)
@@ -35,6 +35,7 @@ interpreted as \code{lower} and \code{y[[2]]} as \code{upper}.}
3535
It is set to \code{TRUE} by default for infix notations.}
3636
\item{NAbounds}{ If \code{lower} (\code{upper}) contains an \code{NA} what should \code{lower<=x} (\code{x<=upper}) return? By default \code{TRUE} so that a missing bound is interpreted as unlimited. }
3737
\item{check}{ Produce error if \code{any(lower>upper)}? \code{FALSE} by default for efficiency, in particular type \code{character}. }
38+
\item{ignore_tzone}{ \code{TRUE} means skip timezone checks among \code{x}, \code{lower}, and \code{upper}. }
3839
}
3940
\details{
4041

0 commit comments

Comments
 (0)