From b620b56a18c06fcec7f4dfbee4a09959ff161e45 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Fri, 25 Sep 2020 16:48:37 -0700 Subject: [PATCH 1/4] create target values using format,strptime so tests 168,2043 work for any LC_TIME --- inst/tests/tests.Rraw | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 058c7db3b2..95e71c2714 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -471,10 +471,13 @@ test(167.3, DT[,plot(b,f),by=.(grp)], data.table(grp=integer())) try(graphics.off(),silent=TRUE) # IDateTime conversion methods that ggplot2 uses (it calls as.data.frame method) -datetimes = c("2011 NOV18 09:29:16", "2011 NOV18 10:42:40", "2011 NOV18 23:47:12", - "2011 NOV19 01:06:01", "2011 NOV19 11:35:34", "2011 NOV19 11:51:09") +# Since %b is e.g. "nov." in LC_TIME=fr_FR.UTF-8 locale, we need to +# have the target/y value in these tests depend on the locale as well. +NOV = format(strptime("2000-11-01", "%Y-%m-%d"), "%b") +x = c("09:29:16","10:42:40","23:47:12","01:06:01","11:35:34","11:51:09") +datetimes = paste0("2011 ", NOV, c(18,18,18,19,19,19), " ", x) DT = IDateTime(strptime(datetimes,"%Y %b%d %H:%M:%S")) -test(168.1, DT[,as.data.frame(itime)], data.frame(V1=as.ITime(x<-c("09:29:16","10:42:40","23:47:12","01:06:01","11:35:34","11:51:09")))) +test(168.1, DT[,as.data.frame(itime)], data.frame(V1=as.ITime(x))) test(168.2, as.character(DT[,as.POSIXct(itime,tz="UTC")]), paste(Sys.Date(), x)) test(168.3, as.character(DT[,as.POSIXct(idate,tz="UTC")]), c("2011-11-18","2011-11-18","2011-11-18","2011-11-19","2011-11-19","2011-11-19")) @@ -15065,10 +15068,13 @@ test(2041.2, DT[, median(time), by=g], DT[c(2,5),.(g=g, V1=time)]) # 'invalid trim argument' with optimization level 1; #1876 test(2042.1, DT[ , as.character(mean(date)), by=g, verbose=TRUE ], data.table(g=c("a","b"), V1=c("2018-01-04","2018-01-21")), - output=msg<-"GForce is on, left j unchanged.*Old mean optimization is on, left j unchanged") -test(2042.2, DT[ , format(mean(date),"%b-%Y")], "Jan-2018") + output=msg<-"GForce is on, left j unchanged.*Old mean optimization is on, left j unchanged") +# Since %b is e.g. "janv." in LC_TIME=fr_FR.UTF-8 locale, we need to +# have the target/y value in these tests depend on the locale as well. +Jan.2018 = format(strptime("2018-01-01", "%Y-%m-%d"), "%b-%Y") +test(2042.2, DT[ , format(mean(date),"%b-%Y")], Jan.2018) test(2042.3, DT[ , format(mean(date),"%b-%Y"), by=g, verbose=TRUE ], # just this case generated the error - data.table(g=c("a","b"), V1=c("Jan-2018","Jan-2018")), output=msg) + data.table(g=c("a","b"), V1=c(Jan.2018, Jan.2018)), output=msg) # gforce wrongly applied to external variable; #875 DT = data.table(x=INT(1,1,1,2,2), y=1:5) From f5d2a6f31f0ac316c5c0ee99d26e27aabe1af84b Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Sat, 26 Sep 2020 08:09:38 -0700 Subject: [PATCH 2/4] mention #3450 and PR#4719 --- NEWS.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS.md b/NEWS.md index 308d427250..56da792b46 100644 --- a/NEWS.md +++ b/NEWS.md @@ -35,6 +35,14 @@ 2. `?.NGRP` now displays the help page as intended, [#4946](https://github.com/Rdatatable/data.table/issues/4649). Thanks to @KyleHaynes for posting the issue, and Cole Miller for the fix. `.NGRP` is a symbol new in v1.13.0; see below in this file. +3. Tests 163 and 2043 were failing in non-English locales such as + `LC_TIME=fr_FR.UTF-8` because computed values use + `strftime(format="%b")` which is locale-dependent e.g. `janv.` + whereas expected values were coded in English e.g. `Jan`, + [#3450](https://github.com/Rdatatable/data.table/issues/3450). Fixed + by changing the expected values to also be locale-dependent + e.g. `janv.` Thanks to @tdhock for + [PR#4719](https://github.com/Rdatatable/data.table/pull/4719). # data.table [v1.13.0](https://github.com/Rdatatable/data.table/milestone/17?closed=1) (24 Jul 2020) From e1c090ce01f1df3d335a6e2d82007eeb5bfd7810 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Sat, 26 Sep 2020 08:09:53 -0700 Subject: [PATCH 3/4] mention issue #3450 --- inst/tests/tests.Rraw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 95e71c2714..46b6716cee 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -472,7 +472,7 @@ try(graphics.off(),silent=TRUE) # IDateTime conversion methods that ggplot2 uses (it calls as.data.frame method) # Since %b is e.g. "nov." in LC_TIME=fr_FR.UTF-8 locale, we need to -# have the target/y value in these tests depend on the locale as well. +# have the target/y value in these tests depend on the locale as well, #3450. NOV = format(strptime("2000-11-01", "%Y-%m-%d"), "%b") x = c("09:29:16","10:42:40","23:47:12","01:06:01","11:35:34","11:51:09") datetimes = paste0("2011 ", NOV, c(18,18,18,19,19,19), " ", x) @@ -15070,7 +15070,7 @@ test(2042.1, DT[ , as.character(mean(date)), by=g, verbose=TRUE ], data.table(g=c("a","b"), V1=c("2018-01-04","2018-01-21")), output=msg<-"GForce is on, left j unchanged.*Old mean optimization is on, left j unchanged") # Since %b is e.g. "janv." in LC_TIME=fr_FR.UTF-8 locale, we need to -# have the target/y value in these tests depend on the locale as well. +# have the target/y value in these tests depend on the locale as well, #3450. Jan.2018 = format(strptime("2018-01-01", "%Y-%m-%d"), "%b-%Y") test(2042.2, DT[ , format(mean(date),"%b-%Y")], Jan.2018) test(2042.3, DT[ , format(mean(date),"%b-%Y"), by=g, verbose=TRUE ], # just this case generated the error From e3bc071aff8253fe66f2b1b1926c187aec2eecc5 Mon Sep 17 00:00:00 2001 From: Matt Dowle Date: Sat, 26 Sep 2020 09:40:20 -0600 Subject: [PATCH 4/4] briefer news item --- NEWS.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index 56da792b46..b5c743994c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -35,14 +35,8 @@ 2. `?.NGRP` now displays the help page as intended, [#4946](https://github.com/Rdatatable/data.table/issues/4649). Thanks to @KyleHaynes for posting the issue, and Cole Miller for the fix. `.NGRP` is a symbol new in v1.13.0; see below in this file. -3. Tests 163 and 2043 were failing in non-English locales such as - `LC_TIME=fr_FR.UTF-8` because computed values use - `strftime(format="%b")` which is locale-dependent e.g. `janv.` - whereas expected values were coded in English e.g. `Jan`, - [#3450](https://github.com/Rdatatable/data.table/issues/3450). Fixed - by changing the expected values to also be locale-dependent - e.g. `janv.` Thanks to @tdhock for - [PR#4719](https://github.com/Rdatatable/data.table/pull/4719). +3. `test.data.table()` failed in non-English locales such as `LC_TIME=fr_FR.UTF-8` due to `Jan` vs `janv.` in tests 168 and 2042, [#3450](https://github.com/Rdatatable/data.table/issues/3450). Thanks to @shrektan for reporting, and @tdhock for making the tests locale-aware. + # data.table [v1.13.0](https://github.com/Rdatatable/data.table/milestone/17?closed=1) (24 Jul 2020)