Skip to content

Commit

Permalink
Add numeric rounding value initialisation in test.data.table() (#6103)
Browse files Browse the repository at this point in the history
* Add setNumericRounding(0) initialisation

Add setNumericRounding(0) initialisation and restore user's value on exit.

* Add test file for testing test.data.table()

Add test file for testing setNumericRounding(0) initialisation in test.data.table().

* Add test for numeric rounding initialisation in test.data.table()

* Add item for numeric rounding initialisation in test.data.table()

* Remove trailing whitespace on two lines

* Remove new test

Remove new test as requested by @MichaelChirico, to avoid nesting a test of test.data.table() in a script run by test.data.table().

* Delete inst/tests/issue_6082_tests.Rraw

Delete inst/tests/issue_6082_tests.Rraw because the test that used it was removed.

* Update NEWS.md

Move test.data.table() numeric rounding initialisation item from Bug Fixes to Notes as requested by @MichaelChirico.
  • Loading branch information
markseeto authored Apr 30, 2024
1 parent 2487c61 commit e04d801
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
12. `print.data.table` now honors `na.print`, as seen in `print.default`, allowing for string replacement of `NA` values when printing. Thanks @HughParsonage for the report and @joshhwuu for the fix.
13. `test.data.table()` now initialises the numeric rounding value to 0 using `setNumericRounding(0)` to avoid failed tests if the user has set a different value, [#6082](https://github.com/Rdatatable/data.table/issues/6082). The user's value is restored on exit. Thanks to @MichaelChirico for the report and for describing the solution, and @markseeto for implementing.

# data.table [v1.15.0](https://github.com/Rdatatable/data.table/milestone/29) (30 Jan 2024)

## BREAKING CHANGE
Expand Down
5 changes: 5 additions & 0 deletions R/test.data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ test.data.table = function(script="tests.Rraw", verbose=FALSE, pkg=".", silent=F
# sample method changed in R 3.6 to remove bias; see #3431 for links and notes
# This can be removed (and over 120 tests updated) if and when the oldest R version we test and support is moved to R 3.6

userNumericRounding = getNumericRounding()
setNumericRounding(0) # Initialise to 0 in case the user has set it to a different value. Restore to user's value when finished.

# TO DO: reinstate solution for C locale of CRAN's Mac (R-Forge's Mac is ok)
# oldlocale = Sys.getlocale("LC_CTYPE")
# Sys.setlocale("LC_CTYPE", "") # just for CRAN's Mac to get it off C locale (post to r-devel on 16 Jul 2012)
Expand Down Expand Up @@ -215,6 +218,8 @@ test.data.table = function(script="tests.Rraw", verbose=FALSE, pkg=".", silent=F
suppressWarnings(do.call("RNGkind",as.list(oldRNG)))
# suppressWarnings for the unlikely event that user selected sample='Rounding' themselves before calling test.data.table()

setNumericRounding(userNumericRounding) # Restore the user's numeric rounding value

# Now output platform trace before error (if any) to be sure to always show it; e.g. to confirm endianness in #4099.
# As one long dense line for cases when 00check.log only shows the last 13 lines of log; to only use up one
# of those 13 line and give a better chance of seeing more of the output before it. Having said that, CRAN
Expand Down

0 comments on commit e04d801

Please sign in to comment.