libnpy icon indicating copy to clipboard operation
libnpy copied to clipboard

"'std::runtime_error' what(): formatting error: typestrings not matching",

Open coreeey opened this issue 2 years ago • 3 comments

I find i can't load the numpy file due to "terminate called after throwing an instance of "'std::runtime_error' what(): formatting error: typestrings not matching", and i tried "std::vector<std::complex> data", std::vector<std::complex> data, std::vector data, std::vector data and so on, it didn't work too, the size of my numpy file is (1, 25, 224,224). here is my code: npy::LoadArrayFromNumpy("00000_1_video.npy", video.shape, video.fortran_order, video.data);

coreeey avatar Aug 11 '22 08:08 coreeey

I convert my numpy file to float and i can copy the d.data, but d.fortran_order is '0', so does it mean that i load the file incorrectly?

coreeey avatar Aug 12 '22 03:08 coreeey

This error message could use some improvement.

Do you know what format your original file was in? What does hexdump -C -n 80 <filename> give you?

fortran_order indicates if the data is column-major (fortran order = True) oder row-major (fortran order = False), so it being 0 could be perfectly correct in many cases.

llohse avatar Aug 15 '22 08:08 llohse

This error maybe because your ndarray type doesn't match c++ std::vector 's type.

You can set ndarray type by np.save(f, array.astype(np.float32))

LamForest avatar Aug 16 '22 10:08 LamForest