Skip to content

Commit 2eb6519

Browse files
Error: flip result when changing to isRealReallyInt*
1 parent 8ac2ae0 commit 2eb6519

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

R/IDateTime.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ round.IDate = function(x, digits=c("weeks", "months", "quarters", "years"), ...)
9999
# TODO: investigate Ops.IDate method a la Ops.difftime
100100
if (inherits(e1, "difftime") || inherits(e2, "difftime"))
101101
internal_error("difftime objects may not be added to IDate, but Ops dispatch should have intervened to prevent this") # nocov
102-
if (isRealReallyInt32(e1) || isRealReallyInt32(e2)) {
102+
if (!isRealReallyInt32(e1) || !isRealReallyInt32(e2)) {
103103
return(`+.Date`(e1, e2))
104104
# IDate doesn't support fractional days; revert to base Date
105105
}
@@ -120,7 +120,7 @@ round.IDate = function(x, digits=c("weeks", "months", "quarters", "years"), ...)
120120
if (inherits(e2, "difftime"))
121121
internal_error("difftime objects may not be subtracted from IDate, but Ops dispatch should have intervened to prevent this") # nocov
122122

123-
if ( isRealReallyInt32(e2) ) {
123+
if ( !isRealReallyInt32(e2) ) {
124124
# IDate deliberately doesn't support fractional days so revert to base Date
125125
return(base::`-.Date`(as.Date(e1), e2))
126126
# can't call base::.Date directly (last line of base::`-.Date`) as tried in PR#3168 because

R/bmerge.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
9292
if (xclass=="integer64" || iclass=="integer64") {
9393
nm = c(iname, xname)
9494
if (xclass=="integer64") { w=i; wc=ic; wclass=iclass; } else { w=x; wc=xc; wclass=xclass; nm=rev(nm) } # w is which to coerce
95-
if (wclass=="integer" || (wclass=="double" && !isRealReallyInt64(w[[wc]]))) {
95+
if (wclass=="integer" || (wclass=="double" && isRealReallyInt64(w[[wc]]))) {
9696
if (verbose) catf("Coercing %s column %s%s to type integer64 to match type of %s.\n", wclass, nm[1L], if (wclass=="double") " (which has integer64 representation, e.g. no fractions)" else "", nm[2L])
9797
set(w, j=wc, value=bit64::as.integer64(w[[wc]]))
9898
} else stopf("Incompatible join types: %s is type integer64 but %s is type double and cannot be coerced to integer64 (e.g. has fractions)", nm[2L], nm[1L])
9999
} else {
100100
# just integer and double left
101101
if (iclass=="double") {
102-
if (!isRealReallyInt32(i[[ic]])) {
102+
if (isRealReallyInt32(i[[ic]])) {
103103
# common case of ad hoc user-typed integers missing L postfix joining to correct integer keys
104104
# we've always coerced to int and returned int, for convenience.
105105
if (verbose) catf("Coercing double column %s (which contains no fractions) to type integer to match type of %s.\n", iname, xname)

R/data.table.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3240,9 +3240,9 @@ is_constantish = function(q, check_singleton=FALSE) {
32403240
if (length(RHS) != nrow(x)) stopf("RHS of %s is length %d which is not 1 or nrow (%d). For robustness, no recycling is allowed (other than of length 1 RHS). Consider %%in%% instead.", operator, length(RHS), nrow(x))
32413241
return(NULL) # DT[colA == colB] regular element-wise vector scan
32423242
}
3243-
if ( mode(x[[col]]) != mode(RHS) || # mode() so that doubleLHS/integerRHS and integerLHS/doubleRHS!isRealReallyInt32 are optimized (both sides mode 'numeric')
3243+
if ( mode(x[[col]]) != mode(RHS) || # mode() so that doubleLHS/integerRHS and integerLHS/doubleRHS&isRealReallyInt32 are optimized (both sides mode 'numeric')
32443244
is.factor(x[[col]])+is.factor(RHS) == 1L || # but factor is also mode 'numeric' so treat that separately
3245-
is.integer(x[[col]]) && isRealReallyInt32(RHS) ) { # and if RHS contains fractions then don't optimize that as bmerge truncates the fractions to match to the target integer type
3245+
is.integer(x[[col]]) && !isRealReallyInt32(RHS) ) { # and if RHS contains fractions then don't optimize that as bmerge truncates the fractions to match to the target integer type
32463246
# re-direct non-matching type cases to base R, as data.table's binary
32473247
# search based join is strict in types. #957, #961 and #1361
32483248
# the mode() checks also deals with NULL since mode(NULL)=="NULL" and causes this return, as one CRAN package (eplusr 0.9.1) relies on

0 commit comments

Comments
 (0)