Closed JaySLee closed 4 years ago
Well the test code in tests/loadFiles.R
is clearly a counter example as it uses int
(with the required and documented argument).
Whoops, I didn't read the documentation closely. My bad!
Ahh, that happens. I'll close this. Feel free to re-open if you find something amiss.
Hi @eddelbuettel, is there a way to read directly numpy boolean arrays with your package? Not sure if I should open a new issue with the request, but I wanted to ask first in case I'm missing something.
I don't know, I have not tried.
It could, the function cnpy::map_type()
(in file src/cnpy.cpp
, and from the cnpy
library implementing the actual functionality of reading NumPy data) appears to have a mapper for boolean type in the NumPy header. That should work for a file written by Python. Our initial focus years ago was just float(64)
and int(32)
plus "neighbouring" types. One issue may be that R has three values for a boolean (!!), namely TRUE
, FALSE
and NA
, whereas Python only has two. But you might get TRUE
and FALSE
in.
These days you can also rely on reticulate
(if you have it installed) for a much heavier and powerful converter for all things Python (including data); I show in the second vignette how to use that.
Hi again,
I might as well mention this as well. If the numpy array is not set to float64 (e.g., float32 or int64), npyLoad() either crashes or shows incorrect values. I haven't looked further into this, but if you want me to suggest changes to the documentation for now, I can do a pull request for that.
Jay