Skip to content

Commit

Permalink
unit tests for split.data.table preserving attributes, #2047
Browse files Browse the repository at this point in the history
  • Loading branch information
jangorecki committed Dec 15, 2018
1 parent 87e48f0 commit 0ef474f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

10. `setDTthreads()` gains `restore_after_fork=`, [#2885](https://github.com/Rdatatable/data.table/issues/2885). The default `NULL` leaves the internal option unchanged which by default is `TRUE`. `data.table` has always switched to single-threaded mode on fork. It used to restore multi-threading after a fork too but problems were reported on Mac and Intel OpenMP library (see 1.10.4 notes below). We are trying again thanks to suggestions and success reported by Kun Ren and Mark Klik in package `fst`. If you experience problems will multi threading after a fork, please restart R and call `setDTthreads(restore_after_fork=FALSE)`.

11. `split` data.table method will now preserve attributes, closes [#2047](https://github.com/Rdatatable/data.table/issues/2047). Thanks to @caneff for reporting.

#### BUG FIXES

1. Providing an `i` subset expression when attempting to delete a column correctly failed with helpful error, but when the column was missing too created a new column full of `NULL` values, [#3089](https://github.com/Rdatatable/data.table/issues/3089). Thanks to Michael Chirico for reporting.
Expand Down
6 changes: 6 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -13160,6 +13160,12 @@ test(1971.2, DT[ , lapply(.SD, sum), .SDcols = patterns('^V[02468]', '^V[48]')],
test(1971.3, DT[ , lapply(.SD, sum), .SDcols = !patterns('^c|i')],
data.table(V1=-6.3, V2=-6.5, V3=1.3, V4=3.4, V5=-0.9, V6=-1.6, V7=-2, V8=-0.4, V9=6.1, V10=-1.8))

# split.data.table now preserves attributes #2047
dt = data.table(x=1:10, y=rep(1:2,each=5))
setattr(dt, "a", 5)
test(1972.1, attr(split(dt,rep(1:2,each=5))[[1]],"a"), 5)
test(1972.2, attr(split(dt, by="y")[[1]],"a"), 5)


###################################
# Add new tests above this line #
Expand Down

0 comments on commit 0ef474f

Please sign in to comment.