Thread: [R-gregmisc-users] SF.net SVN: r-gregmisc:[1792] trunk/gdata/tests/unitTests/runit.unknown.R
Brought to you by:
warnes
|
From: <wa...@us...> - 2014-04-05 15:55:51
|
Revision: 1792
http://sourceforge.net/p/r-gregmisc/code/1792
Author: warnes
Date: 2014-04-05 15:55:48 +0000 (Sat, 05 Apr 2014)
Log Message:
-----------
Apply changes Brian recommned to NAtoUnknown as well as unknownToNA.
Modified Paths:
--------------
trunk/gdata/tests/unitTests/runit.unknown.R
Modified: trunk/gdata/tests/unitTests/runit.unknown.R
===================================================================
--- trunk/gdata/tests/unitTests/runit.unknown.R 2014-04-05 14:40:08 UTC (rev 1791)
+++ trunk/gdata/tests/unitTests/runit.unknown.R 2014-04-05 15:55:48 UTC (rev 1792)
@@ -249,7 +249,42 @@
## Date-time classes
checkIdentical(isUnknown(xDateUnk, unknown=dateUnk), xDateTest)
checkIdentical(isUnknown(xDate1Unk, unknown=dateUnk), xDate1Test)
- checkIdentical(isUnknown(xPOSIXltUnk, unknown=POSIXltUnk), xPOSIXltTest)
+
+ ####
+ ## Per Brian Ripley on 2014-01-15:
+ ##
+ ## On platforms where POSIXlt has a gmtoff component, it does not
+ ## need to be set. So
+ ##
+ ## > z$gmtoff
+ ## [1] 3600 NA
+ ## > xPOSIXltUnk$gmtoff
+ ## [1] 3600 3600
+ ##
+ ## (or sometimes 0, not NA).
+ ##
+ ## So although identical() correctly reports that they differ, this
+ ## is allowed for optional components.
+ ##
+ ## It would also be wrong to use identical() to compare isdst
+ ## components: isdst = -1 means unknown.
+ ##
+ ## Replaced:
+ ## checkIdentical(isUnknown(xPOSIXltUnk, unknown=POSIXltUnk), xPOSIXltTest)
+ ## With:
+ tmp_isUnknown <- isUnknown(xPOSIXltUnk, unknown=POSIXltUnk)
+ tmp_xPOSIXltTest <- xPOSIXlt
+
+ tmp_isUnknown$gmtoff <- NULL # Remove $gmtoff to avoid comparison
+ tmp_xPOSIXltTest$gmtoff <- NULL
+
+ tmp_isUnknownisdst <- NULL # Remove $isdst to avoid comparison
+ tmp_xPOSIXltTest$isdst <- NULL
+
+ checkIdentical(tmp_isUnknown, tmp_xPOSIXltTest)
+ ##
+ ####
+
checkIdentical(isUnknown(xPOSIXlt1Unk, unknown=POSIXltUnk), xPOSIXlt1Test)
checkIdentical(isUnknown(xPOSIXctUnk, unknown=POSIXctUnk), xPOSIXctTest)
checkIdentical(isUnknown(xPOSIXct1Unk, unknown=POSIXctUnk), xPOSIXct1Test)
@@ -333,6 +368,7 @@
checkIdentical(unknownToNA(xDateUnk, unknown=dateUnk), xDate)
checkIdentical(unknownToNA(xPOSIXctUnk, unknown=POSIXctUnk), xPOSIXct)
+ ####
## Per Brian Ripley on 2014-01-15:
##
## On platforms where POSIXlt has a gmtoff component, it does not need to be set. So
@@ -350,6 +386,9 @@
## It would also be wrong to use identical() to compare isdst
## components: isdst = -1 means unknown.
##
+ ## Replaced:
+ ## checkIdentical(unknownToNA(xPOSIXltUnk, unknown=POSIXltUnk), xPOSIXlt)
+ ## With:
tmp_unknownToNA <- unknownToNA(xPOSIXltUnk, unknown=POSIXltUnk)
tmp_xPOSIXlt <- xPOSIXlt
@@ -360,8 +399,8 @@
tmp_xPOSIXlt$isdst <- NULL
checkIdentical(tmp_unknownToNA, tmp_xPOSIXlt)
+ ####
-
## --- lists and data.frames ---
## with vector of single unknown values
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wa...@us...> - 2014-04-05 18:22:18
|
Revision: 1798
http://sourceforge.net/p/r-gregmisc/code/1798
Author: warnes
Date: 2014-04-05 18:22:16 +0000 (Sat, 05 Apr 2014)
Log Message:
-----------
Don't compare optional POSIXlt field. Explicitly compare POSIXlt, with special handling of '-1' unknown value.
Modified Paths:
--------------
trunk/gdata/tests/unitTests/runit.unknown.R
Modified: trunk/gdata/tests/unitTests/runit.unknown.R
===================================================================
--- trunk/gdata/tests/unitTests/runit.unknown.R 2014-04-05 18:19:49 UTC (rev 1797)
+++ trunk/gdata/tests/unitTests/runit.unknown.R 2014-04-05 18:22:16 UTC (rev 1798)
@@ -331,9 +331,58 @@
## Date-time classes
checkIdentical(unknownToNA(xDateUnk, unknown=dateUnk), xDate)
- checkIdentical(unknownToNA(xPOSIXltUnk, unknown=POSIXltUnk), xPOSIXlt)
checkIdentical(unknownToNA(xPOSIXctUnk, unknown=POSIXctUnk), xPOSIXct)
+ ####
+ ## Per Brian Ripley on 2014-01-15:
+ ##
+ ## On platforms where POSIXlt has a gmtoff component, it does not need to be set. So
+ ##
+ ## > z$gmtoff
+ ## [1] 3600 NA
+ ## > xPOSIXltUnk$gmtoff
+ ## [1] 3600 3600
+ ##
+ ## (or sometimes 0, not NA).
+ ##
+ ## So although identical() correctly reports that they differ, this
+ ## is allowed for optional components.
+ ##
+ ## It would also be wrong to use identical() to compare isdst
+ ## components: isdst = -1 means unknown.
+ ##
+ ## Replaced:
+ ## checkIdentical(unknownToNA(xPOSIXltUnk, unknown=POSIXltUnk), xPOSIXlt)
+ ## With:
+ tmp_unknownToNA <- unknownToNA(xPOSIXltUnk, unknown=POSIXltUnk)
+ tmp_xPOSIXlt <- xPOSIXlt
+ ##
+ tmp_unknownToNA$gmtoff <- NULL # Remove $gmtoff to avoid comparison
+ tmp_xPOSIXlt$gmtoff <- NULL
+ ##
+ isdst.unknown <- unique(
+ c(which(is.na(tmp_unknownToNA$isdst) |
+ tmp_unknownToNA$isdst==-1
+ )
+ )
+ ,
+ c(which(is.na(tmp_xPOSIXlt$isdst) |
+ tmp_xPOSIXlt$isdst==-1
+ )
+ )
+
+ )
+ ##
+ checkIdentical(tmp_unknownToNA$isdst[!isdst.unknown],
+ tmp_xPOSIXlt$isds[!isdst.unknown])
+ ##
+ tmp_unknownToNA$isdst <- NULL # Remove $isdst to avoid comparison
+ tmp_xPOSIXlt$isdst <- NULL # by checkIdentical
+ ##
+ checkIdentical(tmp_unknownToNA, tmp_xPOSIXlt)
+ ####
+
+
## --- lists and data.frames ---
## with vector of single unknown values
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wa...@us...> - 2014-04-05 21:08:45
|
Revision: 1801
http://sourceforge.net/p/r-gregmisc/code/1801
Author: warnes
Date: 2014-04-05 21:08:41 +0000 (Sat, 05 Apr 2014)
Log Message:
-----------
Apply same changes to NAToUnknown that were previously applied to
unknownToNA for POSIXlt.
Modified Paths:
--------------
trunk/gdata/tests/unitTests/runit.unknown.R
Modified: trunk/gdata/tests/unitTests/runit.unknown.R
===================================================================
--- trunk/gdata/tests/unitTests/runit.unknown.R 2014-04-05 18:41:50 UTC (rev 1800)
+++ trunk/gdata/tests/unitTests/runit.unknown.R 2014-04-05 21:08:41 UTC (rev 1801)
@@ -478,9 +478,59 @@
## Date-time classes
checkIdentical(NAToUnknown(xDate, unknown=dateUnk), xDateUnk)
- checkIdentical(NAToUnknown(xPOSIXlt, unknown=POSIXltUnk), xPOSIXltUnk)
checkIdentical(NAToUnknown(xPOSIXct, unknown=POSIXctUnk), xPOSIXctUnk)
+
+ ####
+ ## Per Brian Ripley on 2014-01-15:
+ ##
+ ## On platforms where POSIXlt has a gmtoff component, it does not need to be set. So
+ ##
+ ## > z$gmtoff
+ ## [1] 3600 NA
+ ## > xPOSIXltUnk$gmtoff
+ ## [1] 3600 3600
+ ##
+ ## (or sometimes 0, not NA).
+ ##
+ ## So although identical() correctly reports that they differ, this
+ ## is allowed for optional components.
+ ##
+ ## It would also be wrong to use identical() to compare isdst
+ ## components: isdst = -1 means unknown.
+ ##
+ ## Replaced:
+ ## checkIdentical(NAToUnknown(xPOSIXlt, unknown=POSIXltUnk), xPOSIXltUnk)
+ ## With:
+ tmp_NAToUnknown <- NAToUnknown(xPOSIXlt, unknown=POSIXltUnk)
+ tmp_xPOSIXltUnk <- xPOSIXltUnk
+ ##
+ tmp_NAToUnknown$gmtoff <- NULL # Remove $gmtoff to avoid comparison
+ tmp_xPOSIXltUnk$gmtoff <- NULL
+ ##
+ isdst.unknown <- unique(
+ c(which(is.na(tmp_NAToUnknown$isdst) |
+ tmp_NAToUnknown$isdst==-1
+ )
+ )
+ ,
+ c(which(is.na(tmp_xPOSIXltUnk$isdst) |
+ tmp_xPOSIXltUnk$isdst==-1
+ )
+ )
+
+ )
+ ##
+ checkIdentical(tmp_NAToUnknown$isdst[!isdst.unknown],
+ tmp_xPOSIXltUnk$isds[!isdst.unknown])
+ ##
+ tmp_NAToUnknown$isdst <- NULL # Remove $isdst to avoid comparison
+ tmp_xPOSIXltUnk$isdst <- NULL # by checkIdentical
+ ##
+ checkIdentical(tmp_NAToUnknown, tmp_xPOSIXltUnk)
+ ####
+
+
## --- lists and data.frames ---
## with vector of single unknown values
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|