[Rcpp-devel] trying installing RcppCNPy with -std=c++11 (or c++0x) and failed due to incompatible number of arguments
Dirk Eddelbuettel
edd at debian.org
Wed Feb 20 18:51:49 CET 2013
On 20 February 2013 at 12:26, Gong-Yi Liao wrote:
| It seems that we have something to do with type detection, I put some
| console output code to see what type of data are detected while being
| loaded.
|
| In cnpy.h, I add:
|
| ===== cnpy.h ===============
|
| + #define RCPP_HAS_LONG_LONG_TYPES
| #ifdef RCPP_HAS_LONG_LONG_TYPES
| #include <cstdint> // for std::int64_t, needs c++11 switch
| #endif
| ============================
|
| in cnpyMod.cpp: I sightly modified npyLoad function: (between line 61 to 71)
|
| === cnpyMod.cpp ===================
|
| if (shape.size() == 1) {
| if (type == "numeric") {
| + std::cout << "loading numeric (double) from .npy" << std::endl;
| double *p = reinterpret_cast<double*>(arr.data);
| ret = Rcpp::NumericVector(p, p + shape[0]);
| #ifdef RCPP_HAS_LONG_LONG_TYPES
| } else if (type == "integer") {
| + std::cout << "loading int64 from .npy" << std::endl;
| int64_t *p = reinterpret_cast<int64_t*>(arr.data);
| ret = Rcpp::IntegerVector(p, p + shape[0]);
| #endif
| } else {
| arr.destruct();
| Rf_error("Unsupported type in npyLoad");
| }
The "type" variable you test on is _an argument to the function_.
You were supposed to set it to "integer" before you called (and that way we
bypass the testing business).
| ===================================
|
| In python, I generated the data:
|
| ==== in IPython 0.13 ==============
|
| In [3]: save('test.npy', poisson(100,10))
|
| ===================================
Look at the tests/ directory of RcppCNPy. I have regression tests there,
including some (currently commented-out) integer cases on the R side.
I seem to recall that these worked in the very early version. Maybe you can
see of they still do?
Dirk
|
| In R, loaded data and found:
|
| ===== In R 2.15.2 =================
|
| R> library(RcppCNPy); npyLoad('test.npy');quit('yes')
| Loading required package: Rcpp
| loading numeric (double) from .npy
| [1] 5.088876152e-322 4.397184248e-322 5.632348363e-322
| 6.027600879e-322 4.001931731e-322 4.841843329e-322 4.397184248e-322
| 5.632348363e-322 4.347777683e-322
| [10] 4.100744860e-322
|
| =================================
|
| It seems that problem is data type detection, could that be caused by R
| itself? I think Rcpp and RcppCNPy are constrained by R's limitation.
|
| Gong.
|
| On 02/20/2013 07:35 AM, Dirk Eddelbuettel wrote:
| > Gong-Yi,
| >
| > On 19 February 2013 at 19:15, Dirk Eddelbuettel wrote:
| > | I'll commit a fix in a bit.
| >
| > There is now a candidate package 0.2.0.1 at the R-Forge page (or in SVN)
|
| > https://r-forge.r-project.org/R/?group_id=155
| >
| > Could you test that against your integer data and report back?
| >
| > Thanks, Dirk
| >
|
|
| --
| Gong-Yi Liao
| Department of Statistics
| University of Connecticut
|
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list