[Rcpp-commits] r923 - in pkg/Rcpp: . inst inst/unitTests src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Mar 19 18:15:17 CET 2010


Author: edd
Date: 2010-03-19 18:15:17 +0100 (Fri, 19 Mar 2010)
New Revision: 923

Added:
   pkg/Rcpp/inst/unitTests/runit.RcppFrame.R
Modified:
   pkg/Rcpp/NEWS
   pkg/Rcpp/inst/ChangeLog
   pkg/Rcpp/inst/THANKS
   pkg/Rcpp/src/RcppFrame.cpp
   pkg/Rcpp/src/RcppFrame.h
Log:
applied Alistair Gee's patch to ColDatum
added Alistair to inst/THANKS
added simple RcppFrame unit test
update NEWS and ChangeLog


Modified: pkg/Rcpp/NEWS
===================================================================
--- pkg/Rcpp/NEWS	2010-03-19 16:58:22 UTC (rev 922)
+++ pkg/Rcpp/NEWS	2010-03-19 17:15:17 UTC (rev 923)
@@ -1,12 +1,14 @@
 0.7.11	(under develpment)
 
-	o	Vector<> gains a set of templated factory methods "create". create 
+    o	Vector<> gains a set of templated factory methods "create". create 
 	takes up to 20 arguments and can create named or unnamed vectors. 
 	
-	o	Named is no more a class but a templated function. Both interfaces
+    o	Named is no more a class but a templated function. Both interfaces
 	Named(.,.) and Named(.)=. are preserved, and extended to work also on 
 	simple vectors (through Vector<>::create) 
 	
+    o	Applied patch by Alistair Gee to make ColDatum more robust 
+        
 0.7.10  2010-03-15
 
     o	new class Rcpp::S4 whose constructor checks if the object is an S4 object

Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog	2010-03-19 16:58:22 UTC (rev 922)
+++ pkg/Rcpp/inst/ChangeLog	2010-03-19 17:15:17 UTC (rev 923)
@@ -1,22 +1,31 @@
 2010-03-19  Romain Francois <romain at r-enthusiasts.com>
 
-	* src/Rcpp/Named.h: Named is no longer a class, but a templated function. 
+	* src/Rcpp/Named.h: Named is no longer a class, but a templated function.
 	This preserves all the existing interface, but also allows Named to be used
 	in making simple vectors, e.g through the Vector::create factory functions
 
-	* src/Rcpp/Vector.h: Vector gains the "create" factory methods taking up 
+	* src/Rcpp/Vector.h: Vector gains the "create" factory methods taking up
 	to 20 arguments that can be named (using the Argument class or the _ 
 	placeholder)
-	
+
 	* src/Rcpp/make_list.h: removed since Vector::create does the job more generically
 	and more efficently
 
+2010-03-19  Dirk Eddelbuettel  <edd at debian.org>
+
+	* src/Rcpp/Vector.h: Matrix now also accepts a single int in the
+	  constructor to create matrices of square sizes 
+
+	* src/RcppFrame.h: Patch by Alistair Gee to make ColDatum more robust
+	  src/RcppFrame.h: Idem
+        * inst/unitTests/runit.RcppFrame.R: New unit test for RcppFrame
+
 2010-03-16  Romain Francois <romain at r-enthusiasts.com>
 
-	* src/Rcpp/make_list.h: set of helper factories make_list to facilitate 
-	production of named generic vectors. 
-	
-	* src/Rcpp/Named.h: new class Rcpp::Argument similar to Named but does not 
+	* src/Rcpp/make_list.h: set of helper factories make_list to facilitate
+	production of named generic vectors.
+
+	* src/Rcpp/Named.h: new class Rcpp::Argument similar to Named but does not
 	contain the object, just the name. The templated Argument::operator= makes
 	a Named. This allows an application to define a set of arguments that it uses
 	in order to have a nicer construct. see the runit.Argument.R file for an example

Modified: pkg/Rcpp/inst/THANKS
===================================================================
--- pkg/Rcpp/inst/THANKS	2010-03-19 16:58:22 UTC (rev 922)
+++ pkg/Rcpp/inst/THANKS	2010-03-19 17:15:17 UTC (rev 923)
@@ -2,6 +2,7 @@
 In alphabetical order:
 
 Laurent Gautier         for help on R internals
+Alistair Gee		for a patch making ColDatum more robust
 Uwe Ligges              for help with Windows (32 and 64 bit) build issues
 David Reiss             for the first-ever contributed patch (Rcpp*View)
 Brian Ripley            for help Win64 build issues

Added: pkg/Rcpp/inst/unitTests/runit.RcppFrame.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.RcppFrame.R	                        (rev 0)
+++ pkg/Rcpp/inst/unitTests/runit.RcppFrame.R	2010-03-19 17:15:17 UTC (rev 923)
@@ -0,0 +1,49 @@
+#!/usr/bin/r -t
+#
+# Copyright (C) 2010	Dirk Eddelbuettel and Romain Francois
+#
+# This file is part of Rcpp.
+#
+# Rcpp is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# Rcpp is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
+
+.setUp <- function(){
+    suppressMessages( require( inline ) )
+}
+
+test.RcppFrame <- function() {
+    src <- 'std::vector<std::string> names;
+            names.push_back("A");
+            names.push_back("B");
+            names.push_back("C");
+            RcppFrame fr(names);
+
+            std::vector<ColDatum> colDatumVector(3);
+            colDatumVector[0].setDoubleValue(1.23);
+            colDatumVector[1].setIntValue(42);
+            colDatumVector[2].setLogicalValue(0);
+            fr.addRow(colDatumVector);
+
+            colDatumVector[0].setDoubleValue(4.56);
+            colDatumVector[1].setIntValue(21);
+            colDatumVector[2].setLogicalValue(1);
+            fr.addRow(colDatumVector);
+
+            RcppResultSet rs;
+            rs.add("data.frame", fr);
+	    return rs.getReturnList();';
+    funx <- cfunction(signature(), src, Rcpp=TRUE)
+    dframe <- data.frame(funx()[[1]]) ## needs a data.frame() call on first list elem
+    checkEquals(dframe, data.frame(A=c(1.23,4.56), B=c(42,21), C=c(FALSE,TRUE)), msg = "RcppFrame")
+}
+

Modified: pkg/Rcpp/src/RcppFrame.cpp
===================================================================
--- pkg/Rcpp/src/RcppFrame.cpp	2010-03-19 16:58:22 UTC (rev 922)
+++ pkg/Rcpp/src/RcppFrame.cpp	2010-03-19 17:15:17 UTC (rev 923)
@@ -22,7 +22,7 @@
 
 #include <RcppFrame.h>
 
-ColDatum::ColDatum() : level(0) { }
+ColDatum::ColDatum() : type(COLTYPE_UNKNOWN), level(0) { }
 
 ColDatum::ColDatum(const ColDatum& datum) {
     // Need deep copy so contruction/destruction is synchronized.

Modified: pkg/Rcpp/src/RcppFrame.h
===================================================================
--- pkg/Rcpp/src/RcppFrame.h	2010-03-19 16:58:22 UTC (rev 922)
+++ pkg/Rcpp/src/RcppFrame.h	2010-03-19 17:15:17 UTC (rev 923)
@@ -30,7 +30,8 @@
 enum ColType {			// Supported data frame column types.
     COLTYPE_DOUBLE, COLTYPE_INT, COLTYPE_STRING,
     COLTYPE_FACTOR, COLTYPE_LOGICAL, 
-    COLTYPE_DATE, COLTYPE_DATETIME 
+    COLTYPE_DATE, COLTYPE_DATETIME,
+    COLTYPE_UNKNOWN = -1
 };
 class ColDatum;			// forward declaration, see below
 



More information about the Rcpp-commits mailing list