Open ghost opened 6 years ago
Update: problem #1 was fixed with a debugger. I now declare the size and contents of my containers:
vector < double > vrmsd(max,99.9);
vector<vector
Problem #2 remains:
ValueError: descr is not a valid dtype descriptor: '<?24'
Same problem (ValueError: descr is not a valid dtype descriptor: '<?24') here, any hints?
Alright, figured it out. In my case i wanted to save a matrix of type std::vector<std::vector<double> >
, but my mistake was to give &matrix[0]
instead of &matrix[0][0]
to the npy_save
function.
I was wong. To save an std::vector<std::vector<double> >
, you need to first flatten it.
I am writing two npy formatted files in my C++ program as follows:
vector < vector < int> > vhist;
vector < double > vrmsd;
. . .
cerr <<"saving " << nfeat << " x " << histsize << " features\n" ; cnpy::npy_save(fout,&vhist[0],{nfeat,histsize},"w"); cnpy::npy_save(frmsd,&vrmsd,{nfeat},"w"); cerr << "done saving features\n";
Where the output is:
saving 40339 x 64000 features done saving features
There are two issues:
1) fout ("dock_feat.npy")contains only a header strings dock_feat.npy NUMPY {'descr': '<?24', 'fortran_order': False, 'shape': (40339, 64000), }
2) The descr field in both fout and frmsd is not accepted by np.load()
ValueError: descr is not a valid dtype descriptor: '<?24'