[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 17:54:03 CET 2013


On 20 February 2013 at 11:07, Gong-Yi Liao wrote:
| I have build the updated RppCNPy package (0.2.0.1) and load it in R 
| 3.0.0 (which supports long double and may be long long int) and R 2.15.2 
| , npyLoad now can load data without the 'BigEndian' problem but with 
| another even weirder problem:

For the lists' benefit, I first got this as a private mail and replied the
following 

  I have an r-devel build here too.

  But you misunderstand: R 3.0.0 uses double for indices, hence "larger".  R
  still only knows "integer" and "numeric", effectively int and double.

  I am just about to head to work and cannot look at this all that closely. I
  think we need to proceed in stages

  i)   save data from Python (you're there)
  ii)  read it in RcppCNPy at the C++ level, make sure values are correct
  iii) make sure dim + orientation is correct (col major vs row major,
       sometimes we need to transpose
  iv)  cast as needed to get values to R

  The case may mean a lossy cast to integer, or a promotion to numeric.  We
  have to think about this.

  Likewise we have to test i) to iv) the other way around from R to Python.

  Thanks!

  Dirk

With regards to the subsequent emails:  No, I don't think int64 helps here
(as it is not a native R type).

Dirk


| 
| ## Case 1:
| === In Python =====
| [1]: save('test.npy', pylab.poisson(lam=5.6, size=10))
| 
| == In R 3.0.0. ======
| R> npyLoad('test.npy')
|   [1] 1.976262583e-323 1.482196938e-323 1.482196938e-323 
| 9.881312917e-324  0.000000000e+00 1.482196938e-323 4.940656458e-324 
| 2.964393875e-323 1.482196938e-323
| 
| ## Case 2:
| === In Python =========
| In [12]: save('test.npy', [numpy.int(x) for x in poisson(3.5, 10)])
| 
| == In R 3.0.0 ==========
| R> npyLoad('test.npy')
|   [1] 9.881312917e-324 1.976262583e-323 2.470328229e-323 
| 1.482196938e-323 3.458459521e-323 1.482196938e-323 9.881312917e-324 
| 2.964393875e-323 1.976262583e-323
| [10] 9.881312917e-324
| 
| Case 3:
| == In Python ========
| In [13]: save('test.npy', [double(x) for x in poisson(3.5, 10)])
| 
| == In R ===========
| R> npyLoad('test.npy')
|   [1] 4 8 4 4 5 2 3 5 5 3
| 
| It seems that something needs to be modified in R that we can load some 
| int64 type data. I am not sure if the orphaned 'int64' package can help, 
| because in the first case, I have tested:
| 
| R> as.int64(npyLoad('test.npy')[1])
| [1] 0
| 
| Gong.
| 
| 
| 
| 
| 
| 
| 
| On 02/19/2013 08:15 PM, Dirk Eddelbuettel wrote:
| > Good news, got to look at this on train commute home. It is plainly my
| > error. And a fix (of just adding #define R_NO_REMAP before #include'ing
| > Rinternals.h) will be forthcoming.  The "length" gave it away.
| >
| > You can also simply not #include<iomanip> and the error is also avoided.
| >
| > I'll commit a fix in a bit.
| >
| > Dirk
| >
| 
| 
| -- 
| Gong-Yi Liao
| Department of Statistics
| University of Connecticut
| 
| 
| -- 
| Gong-Yi Liao
| Department of Statistics
| University of Connecticut
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com  


More information about the Rcpp-devel mailing list