You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to put a 3D array of dimension (10000, 160, 346) in an .npy file using the append mode as shown in the code below:
#include"cnpy.h"
#include<vector>
#include<cstdlib>constexprint N = 346*160;
intmain(int argc, char* argv[]) {
int ROWS = 10000;
// Create a vector
std::vector<double> vec (N,0);
// Fill the vector with datafor(int i=0; i < N; i++) {
vec[i] = i;
}
// Append the vector ROWS number of times into an npz filefor (int t=0; t<ROWS; t++){
cnpy::npy_save("sample.npy", &vec[0], {1,160,346}, "a");
}
return0;
}
If I now try to open this file using the following Python code:
importnumpyasnpx=np.load('sample.npy')
I get the following error:
ValueError: cannot reshape array of size 553599998 into shape (10000,160,346)
So, the size of array in the saved sample.npy is 2 Bytes smaller than what's expected. I have observed arrays upto 16 Bytes off from the expected size for larger size. Could you help resolve this issue?
The text was updated successfully, but these errors were encountered:
I'm trying to put a 3D array of dimension
(10000, 160, 346)
in an.npy
file using the append mode as shown in the code below:If I now try to open this file using the following Python code:
I get the following error:
So, the size of array in the saved
sample.npy
is 2 Bytes smaller than what's expected. I have observed arrays upto 16 Bytes off from the expected size for larger size. Could you help resolve this issue?The text was updated successfully, but these errors were encountered: