Closed bbogart closed 4 years ago
That seems ... weird and unfortunate. Look e.g. at the file tests/createFiles.py which has been there since 2012 (!!). Reading (basic) 32-bit integer and 64 bit double is practically all we have done since day one, so I am not sure what is different with your file. But I am also less experienced in NumPy so I can't tell if you write the file differently, or if NumPy changed something or ...
Can you do me the favour and check if the basic tests in the package work on your system? (They should, I am on Ubuntu too and CRAN tests these things too...)
Found it, possibly, at the bottom of #25. We apparently only take 64bit integers from Python (likely due to a restriction in the CNPy library).
Can you try with 64 bit integers?
Here is an alternative for you: using package reticulate as described in the second vignette.
Very briefly:
R> library(reticulate)
R> np <- import("numpy")
R> np$load("array_int32.npy")
[,1]
[1,] 0
[2,] 0
[3,] 0
[4,] 1
[5,] 1
[6,] 1
[7,] 0
[8,] 1
[9,] 0
[10,] 1
R>
where array_int32.npy
is your file.
CNpy always had a limitation for 64 bit integers; reticulate
is doing more mapping from NumPy and is probably a good bet for you.
Here is my numpy array, here in npy
Written to disk with:
numpy.save("array_int32.npy", arrayInt)
Loading in R gives me very different values:
I'm using the CRAN package of RcppCNPy installed today with R 3.6.3 and numpy 1.13.3 on Ubuntu 18.04.4 LTS.