Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
eb1a309
pre-store INHERITS
mattdowle Sep 21, 2021
33b1dc8
remove dtwiddle overhead
mattdowle Sep 21, 2021
0bc97fb
raised XIND
mattdowle Sep 21, 2021
53ef072
trace recursive calls
mattdowle Sep 22, 2021
e40456f
Merge branch 'master' into bmerge_numeric
mattdowle Sep 25, 2021
f26b878
IVAL not needed as DO() argument
mattdowle Sep 25, 2021
9e45e84
removed rollLow, rollUp, lowmax and uppmax
mattdowle Sep 25, 2021
a11f678
deal with NA/NaN up front
mattdowle Sep 26, 2021
d18a6f9
turn off test 1197.2 as bmerge now ignores setNumericRounding which i…
mattdowle Sep 26, 2021
325f28b
reinstated lowmax and uppmax with better comment why they are needed
mattdowle Sep 27, 2021
b3f43c9
more vars added to trace
mattdowle Sep 28, 2021
480071b
turn off trace as the 2 MAX's did fix test 936 & 937 after all
mattdowle Sep 30, 2021
24ec8a4
expand tests 936 and 937
mattdowle Sep 30, 2021
bbbe2d0
Merge branch 'master' into bmerge_numeric
mattdowle Sep 30, 2021
835f9b8
separate BINX from DO, move NA/NaN treatment into REALSXP case, and a…
mattdowle Oct 5, 2021
b013206
Merge branch 'master' into bmerge_numeric
mattdowle Oct 16, 2021
301b197
fix ilow/iupp finding when NA_REAL were found up front
mattdowle Oct 18, 2021
edc52a8
better variable name: not_NA_MATCH=>SEARCH_EQUAL_IROW
mattdowle Oct 18, 2021
9b2ef80
non-equi tests back on but segfault in 1648.005
mattdowle Oct 18, 2021
80064ad
fix 1647.8
mattdowle Oct 18, 2021
92b9783
fixed segfault in 1648.005 due to all-NA/NaN on one side when non-equ…
mattdowle Oct 19, 2021
f317c65
under non-equi >= and <= NA match to NA and NaN to NaN; now passes al…
mattdowle Oct 19, 2021
66cfc7e
coverage
mattdowle Oct 19, 2021
89e728f
Merge branch 'master' into bmerge_numeric
ben-schwen Jun 23, 2026
8e8cbbe
clean up merge
ben-schwen Jun 23, 2026
a01a10e
add atime test
ben-schwen Jun 25, 2026
70ba268
update bmerge numeric
ben-schwen Jun 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci/atime/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -424,5 +424,6 @@ test.list <- atime::atime_test_list(
seconds.limit = 1,
expr = data.table:::`[.data.table`(dt, , base::max(V1, na.rm = TRUE), by = id)),


tests=extra.test.list)
# nolint end: undesirable_operator_linter.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

3. options `"datatable.old.matrix.autoname"` is now `FALSE` by default, meaning `names(data.table(x=1, cbind(1)))` is now `c("x", "V2")`. Toggle the option to retain the old behavior for now; future releases will work to remove this possibility. See the release notes for 1.18.0, item 1 under `NOTE OF INTENDED FUTURE POTENTIAL BREAKING CHANGES`.

4. Joins on numeric (`double`, including `POSIXct`) columns are no longer affected by `setNumericRounding()`, and always use exact matching as with the default `setNumericRounding(0L)`. If you relied on `setNumericRounding(1L)` or `setNumericRounding(2L)` to match nearly-equal numeric values in joins, round those columns explicitly before joining. `setNumericRounding()` continues to affect grouping and ordering. Numeric joins, especially rolling joins, are faster as a result. Thanks @jangorecki for the PR.

### NEW FEATURES

1. `nafill()`, `setnafill()` extended to work on logical, factor and character vectors (part of [#3992](https://github.com/Rdatatable/data.table/issues/3992)). Includes support for `Date`, `IDate`, `POSIXct` and character vectors. Thanks @jangorecki for the request and @jangorecki, @MichaelChirico and @ben-schwen for the PRs.
Expand Down
12 changes: 9 additions & 3 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -2741,8 +2741,14 @@ test(932, DT[J(c(0,2,6,8)), roll=+Inf, rollends=TRUE, v], INT(1,1,6,7))
test(933, DT[J(c(0,2,6,8)), roll=-Inf, rollends=TRUE, v], INT(1,2,7,7))
test(934, DT[J(c(0,2,6,8)), roll=+Inf, v], INT(NA,1,6,7))
test(935, DT[J(c(0,2,6,8)), roll=-Inf, v], INT(1,2,7,NA))
test(936, DT[J(c(-10,-1,2,12,13)), roll=5, rollends=TRUE, v], INT(NA,1,1,7,NA))
test(937, DT[J(c(-10,-1,2,12,13)), roll=-5, rollends=TRUE, v], INT(NA,1,2,7,NA))
test(936.1, DT[J(c(-10,-1,2,12,13)), roll=5, rollends=TRUE, v], INT(NA,1,1,7,NA))
test(936.2, DT[J(c(-10,-1,-4,2,12,9,13)), roll=5, rollends=TRUE, v], INT(NA,1,1,1,7,7,NA)) # include -4 (exactly row1-roll) and out-of-order too
test(936.3, DT[J(c(-10,-1,2,12,13)), roll=5, v], INT(NA,NA,1,7,NA)) # default rollends when roll>0 is c(FALSE,TRUE)
test(936.4, DT[J(c(-10,-1,-4,2,12,13,9)), roll=5, v], INT(NA,NA,NA,1,7,NA,7))
test(937.1, DT[J(c(-10,-1,2,12,13)), roll=-5, rollends=TRUE, v], INT(NA,1,2,7,NA))
test(937.2, DT[J(c(-10,-1,-4,2,12,9,13)), roll=-5, rollends=TRUE, v], INT(NA,1,1,2,7,7,NA))
test(937.3, DT[J(c(-10,-1,2,12,13)), roll=-5, v], INT(NA,1,2,NA,NA))
test(937.4, DT[J(c(-10,-1,-4,2,12,9,13)), roll=-5, v], INT(NA,1,1,2,NA,NA,NA))
test(938, DT[J(c(-10,2,6,7,8)), roll="nearest", v], INT(1,1,7,7,7))
test(939, DT[J(c(-10,2,6,7,8)), roll="nearest", rollends=c(TRUE,FALSE), v], INT(1,1,7,7,NA))
test(940, DT[J(c(-10,2,6,7,8)), roll="nearest", rollends=c(FALSE,TRUE), v], INT(NA,1,7,7,7))
Expand Down Expand Up @@ -4349,7 +4355,7 @@ test(1196.1, DT[,.N,by=val]$N, INT(1,1,1,1))
test(1196.2, DT[.(x),.N], 1L)
old_rounding = setNumericRounding(2L) # default is 0
test(1197.1, DT[,.N,by=val]$N, INT(1,1,2))
test(1197.2, DT[.(x),.N], 2L)
test(1197.2, DT[.(x),.N], 1L) # bmerge ignores setNumericRounding.
setNumericRounding(old_rounding)

DT = data.table(id=INT(1,2,1), val1=3:1, val2=3:1, val3=list(2:3,4:6,7:10)) # 5380
Expand Down
11 changes: 6 additions & 5 deletions man/setNumericRounding.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
\alias{getNumericRounding}
\title{ Change or turn off numeric rounding }
\description{
Change rounding to 0, 1 or 2 bytes when joining, grouping or ordering numeric
Change rounding to 0, 1 or 2 bytes when grouping or ordering numeric
(i.e. double, POSIXct) columns.
}
\usage{
Expand All @@ -15,9 +15,9 @@ getNumericRounding()
}
\details{
Computers cannot represent some floating point numbers (such as 0.6)
precisely, using base 2. This leads to unexpected behaviour when joining or
grouping columns of type 'numeric'; i.e. 'double', see example below. In
cases where this is undesirable, data.table allows rounding such data up to
precisely, using base 2. This can lead to unexpected behaviour when grouping
columns of type 'numeric'; i.e. 'double', see example below. In cases where this
is undesirable, data.table allows rounding such data up to
approximately 11 significant figures which is plenty of digits for many cases.
This is achieved by rounding the last 2 bytes off the significand. Other possible
values are 1 byte rounding, or no rounding (full precision, default).
Expand Down Expand Up @@ -50,7 +50,8 @@ DT[.(0.6)] # no match, can be confusing since 0.6 is clearly there in DT
# happens due to floating point representation limitations

setNumericRounding(2) # round off last 2 bytes
DT[.(0.6)] # works
DT[.(0.6)] # numeric joins always use full precision, hence, still no match
DT[,.N,by=a] # grouping uses rounding

# using type 'numeric' for integers > 2^31 (typically ids)
DT = data.table(id = c(1234567890123, 1234567890124, 1234567890125), val=1:3)
Expand Down
Loading
Loading