[Rcpp-commits] r1587 - pkg/Rcpp/inst/unitTests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jun 18 02:32:05 CEST 2010
Author: edd
Date: 2010-06-18 02:32:04 +0200 (Fri, 18 Jun 2010)
New Revision: 1587
Modified:
pkg/Rcpp/inst/unitTests/runit.DataFrame.R
Log:
two more DataFrame tests
Modified: pkg/Rcpp/inst/unitTests/runit.DataFrame.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.DataFrame.R 2010-06-17 21:21:14 UTC (rev 1586)
+++ pkg/Rcpp/inst/unitTests/runit.DataFrame.R 2010-06-18 00:32:04 UTC (rev 1587)
@@ -31,6 +31,24 @@
checkEquals( fun(DF), DF, msg = "DataFrame pass-through")
}
+test.DataFrame.index.byName <- function() {
+ DF <- data.frame(a=1:3, b=c("a","b","c"))
+ fun <- cppfunction( signature(x='ANY'), '
+ DataFrame df(x) ;
+ return df["a"];
+ ' )
+ checkEquals( fun(DF), DF$a, msg = "DataFrame column by name")
+}
+
+test.DataFrame.index.byPosition <- function() {
+ DF <- data.frame(a=1:3, b=c("a","b","c"))
+ fun <- cppfunction( signature(x='ANY'), '
+ DataFrame df(x) ;
+ return df[0];
+ ' )
+ checkEquals( fun(DF), DF$a, msg = "DataFrame column by position")
+}
+
test.DataFrame.CreateOne <- function() {
DF <- data.frame(a=1:3)
fun <- cppfunction( signature(), '
@@ -54,9 +72,9 @@
}
test.DataFrame.SlotProxy <- function(){
-
+
setClass("track", representation(x="data.frame", y = "function"))
- tr1 <- new( "track", x = iris, y = rnorm )
+ tr1 <- new( "track", x = iris, y = rnorm )
fun <- cppfunction( signature(x="ANY", y="character"), '
S4 o(x) ;
return DataFrame( o.slot( as<std::string>(y) )) ;
@@ -66,7 +84,7 @@
}
test.DataFrame.AttributeProxy <- function(){
-
+
tr1 <- structure( NULL, x = iris, y = rnorm )
fun <- cppfunction( signature(x="ANY", y="character"), '
List o(x) ;
@@ -74,7 +92,7 @@
' )
checkTrue( identical( fun(tr1, "x"), iris) , msg = "DataFrame( AttributeProxy )" )
checkException( fun(tr1, "y"), msg = "DataFrame( AttributeProxy ) -> exception" )
-
+
}
test.DataFrame.CreateTwo.stringsAsFactors <- function() {
@@ -86,8 +104,8 @@
s[1] = "b";
s[2] = "c";
return DataFrame::create(
- _["a"] = v,
- _["b"] = s,
+ _["a"] = v,
+ _["b"] = s,
_["stringsAsFactors"] = false );
' )
checkEquals( fun(), DF, msg = "DataFrame create2 stringsAsFactors = false")
More information about the Rcpp-commits
mailing list