[Rprotobuf-commits] r881 - papers/jss

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Mar 24 21:33:36 CET 2014


Author: murray
Date: 2014-03-24 21:33:35 +0100 (Mon, 24 Mar 2014)
New Revision: 881

Added:
   papers/jss/int64.proto
Modified:
   papers/jss/article.R
   papers/jss/article.Rnw
Log:
Better fix.  Add a new proto with only the examples we need for this
paper rather than pulling in all fo the complexity of TestAllTypes or
faking it with CodeInput/CodeOutput.



Modified: papers/jss/article.R
===================================================================
--- papers/jss/article.R	2014-03-24 20:25:09 UTC (rev 880)
+++ papers/jss/article.R	2014-03-24 20:33:35 UTC (rev 881)
@@ -173,19 +173,15 @@
 
 
 ###################################################
-### code chunk number 22: article.Rnw:987-994
+### code chunk number 22: article.Rnw:987-990
 ###################################################
-if (!exists("protobuf_unittest.TestAllTypes",
-            "RProtoBuf:DescriptorPool")) {
-    unittest.proto.file <- system.file("unitTests", "data",
-                                       "unittest.proto",
-                                       package="RProtoBuf")
-    readProtoFiles(file=unittest.proto.file)
+if (!exists("JSSPaper.Example1", "RProtoBuf:DescriptorPool")) {
+    readProtoFiles(file="int64.proto")
 }
 
 
 ###################################################
-### code chunk number 23: article.Rnw:1016-1020
+### code chunk number 23: article.Rnw:1012-1016
 ###################################################
 as.integer(2^31-1)
 as.integer(2^31 - 1) + as.integer(1)
@@ -194,27 +190,27 @@
 
 
 ###################################################
-### code chunk number 24: article.Rnw:1031-1032
+### code chunk number 24: article.Rnw:1027-1028
 ###################################################
 2^53 == (2^53 + 1)
 
 
 ###################################################
-### code chunk number 25: article.Rnw:1044-1047
+### code chunk number 25: article.Rnw:1040-1043
 ###################################################
-test <- new(protobuf_unittest.TestAllTypes)
+test <- new(JSSPaper.Example1)
 test$repeated_int64 <- c(2^53, 2^53+1)
 length(unique(test$repeated_int64))
 
 
 ###################################################
-### code chunk number 26: article.Rnw:1054-1055
+### code chunk number 26: article.Rnw:1050-1051
 ###################################################
 test$repeated_int64 <- c("9007199254740992", "9007199254740993")
 
 
 ###################################################
-### code chunk number 27: article.Rnw:1066-1072
+### code chunk number 27: article.Rnw:1062-1068
 ###################################################
 options("RProtoBuf.int64AsString" = FALSE)
 test$repeated_int64
@@ -225,20 +221,20 @@
 
 
 ###################################################
-### code chunk number 28: article.Rnw:1075-1076
+### code chunk number 28: article.Rnw:1071-1072
 ###################################################
 options("RProtoBuf.int64AsString" = FALSE)
 
 
 ###################################################
-### code chunk number 29: article.Rnw:1093-1095
+### code chunk number 29: article.Rnw:1089-1091
 ###################################################
 msg <- serialize_pb(iris, NULL)
 identical(iris, unserialize_pb(msg))
 
 
 ###################################################
-### code chunk number 30: article.Rnw:1126-1129
+### code chunk number 30: article.Rnw:1122-1125
 ###################################################
 datasets <- as.data.frame(data(package="datasets")$results)
 datasets$name <- sub("\\s+.*$", "", datasets$Item)
@@ -246,13 +242,13 @@
 
 
 ###################################################
-### code chunk number 31: article.Rnw:1139-1140
+### code chunk number 31: article.Rnw:1135-1136
 ###################################################
 m <- sum(sapply(datasets$name, function(x) can_serialize_pb(get(x))))
 
 
 ###################################################
-### code chunk number 32: article.Rnw:1153-1160
+### code chunk number 32: article.Rnw:1149-1156
 ###################################################
 attr(CO2, "formula")
 msg <- serialize_pb(CO2, NULL)
@@ -264,7 +260,7 @@
 
 
 ###################################################
-### code chunk number 33: article.Rnw:1176-1195
+### code chunk number 33: article.Rnw:1172-1191
 ###################################################
 datasets$object.size <- unname(sapply(datasets$name, function(x) object.size(eval(as.name(x)))))
 
@@ -288,7 +284,7 @@
 
 
 ###################################################
-### code chunk number 34: article.Rnw:1403-1408
+### code chunk number 34: article.Rnw:1399-1404
 ###################################################
 require(RProtoBuf)
 require(HistogramTools)
@@ -298,7 +294,7 @@
 
 
 ###################################################
-### code chunk number 35: article.Rnw:1476-1483 (eval = FALSE)
+### code chunk number 35: article.Rnw:1472-1479 (eval = FALSE)
 ###################################################
 ## library("RProtoBuf")
 ## library("httr")
@@ -310,7 +306,7 @@
 
 
 ###################################################
-### code chunk number 36: article.Rnw:1542-1558 (eval = FALSE)
+### code chunk number 36: article.Rnw:1538-1554 (eval = FALSE)
 ###################################################
 ## library("httr")       
 ## library("RProtoBuf")
@@ -331,7 +327,7 @@
 
 
 ###################################################
-### code chunk number 37: article.Rnw:1562-1565 (eval = FALSE)
+### code chunk number 37: article.Rnw:1558-1561 (eval = FALSE)
 ###################################################
 ## fnargs <- unserialize_pb(inputmsg)
 ## val <- do.call(stats::rnorm, fnargs)

Modified: papers/jss/article.Rnw
===================================================================
--- papers/jss/article.Rnw	2014-03-24 20:25:09 UTC (rev 880)
+++ papers/jss/article.Rnw	2014-03-24 20:33:35 UTC (rev 881)
@@ -984,20 +984,16 @@
 choose another type (such as enum or integer) capable of storing three
 distinct values.
 
-<<echo=FALSE,print=FALSE,eval=FALSE>>=
-if (!exists("protobuf_unittest.TestAllTypes",
-            "RProtoBuf:DescriptorPool")) {
-    unittest.proto.file <- system.file("unitTests", "data",
-                                       "unittest.proto",
-                                       package="RProtoBuf")
-    readProtoFiles(file=unittest.proto.file)
+<<echo=FALSE,print=FALSE>>=
+if (!exists("JSSPaper.Example1", "RProtoBuf:DescriptorPool")) {
+    readProtoFiles(file="int64.proto")
 }
 @
 
 % We want a cleaner error message here.
 \begin{CodeChunk}
 \begin{CodeInput}
-R> a <- new(protobuf_unittest.TestAllTypes)
+R> a <- new(JSSPaper.Example1)
 R> a$optional_bool <- TRUE
 R> a$optional_bool <- FALSE
 R> a$optional_bool <- NA
@@ -1041,27 +1037,19 @@
 If we try to set an int64 field in \proglang{R} to double values, we lose
 precision:
 
-% We want a cleaner error message here.
-\begin{CodeChunk}
-\begin{CodeInput}
-R> test <- new(protobuf_unittest.TestAllTypes)
-R> test$repeated_int64 <- c(2^53, 2^53+1)
-R> length(unique(test$repeated_int64))
-\end{CodeInput}
-\begin{CodeOutput}
-[1] 1
-\end{CodeOutput}
-\end{CodeChunk}
+<<>>=
+test <- new(JSSPaper.Example1)
+test$repeated_int64 <- c(2^53, 2^53+1)
+length(unique(test$repeated_int64))
+@
 
 But when the values are specified as character strings, \pkg{RProtoBuf}
 will automatically coerce them into a true 64-bit integer types 
 before storing them in the Protocol Buffer message:
 
-\begin{CodeChunk}
-\begin{CodeInput}
-R> test$repeated_int64 <- c("9007199254740992", "9007199254740993")
-\end{CodeInput}
-\end{CodeChunk}
+<<>>=
+test$repeated_int64 <- c("9007199254740992", "9007199254740993")
+@
 
 When reading the value back into \proglang{R}, numeric types are returned by
 default, but when the full precision is required a character value
@@ -1071,34 +1059,14 @@
 packages such as \pkg{int64} \citep{int64} or \pkg{bit64}
 \citep{bit64} which represent 64-bit integers in \proglang{R}.
 
-\begin{CodeChunk}
-\begin{CodeInput}
-R> options("RProtoBuf.int64AsString" = FALSE)
-R> test$repeated_int64
-\end{CodeInput}
-\begin{CodeOutput}
-[1] 9.007e+15 9.007e+15
-\end{CodeOutput}
-\begin{CodeInput}
-R> length(unique(test$repeated_int64))
-\end{CodeInput}
-\begin{CodeOutput}
-[1] 1
-\end{CodeOutput}
-\begin{CodeInput}
-R> options("RProtoBuf.int64AsString" = TRUE)
-R> test$repeated_int64
-\end{CodeInput}
-\begin{CodeOutput}
-[1] "9007199254740992" "9007199254740993"
-\end{CodeOutput}
-\begin{CodeInput}
-R> length(unique(test$repeated_int64))
-\end{CodeInput}
-\begin{CodeOutput}
-[1] 2
-\end{CodeOutput}
-\end{CodeChunk}
+<<>>=
+options("RProtoBuf.int64AsString" = FALSE)
+test$repeated_int64
+length(unique(test$repeated_int64))
+options("RProtoBuf.int64AsString" = TRUE)
+test$repeated_int64
+length(unique(test$repeated_int64))
+@
 
 <<echo=FALSE,print=FALSE>>=
 options("RProtoBuf.int64AsString" = FALSE)

Added: papers/jss/int64.proto
===================================================================
--- papers/jss/int64.proto	                        (rev 0)
+++ papers/jss/int64.proto	2014-03-24 20:33:35 UTC (rev 881)
@@ -0,0 +1,6 @@
+package JSSPaper;
+
+message Example1 {
+  optional bool optional_bool = 1;
+  repeated int64 repeated_int64 = 2;
+}
\ No newline at end of file



More information about the Rprotobuf-commits mailing list