Skip to content

Commit c9b559b

Browse files
committed
Update the interface to libnpy
1 parent 6ad28d1 commit c9b559b

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

source/source_pw/hamilt_ofdft/kedf_ml.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,24 @@ void KEDF_ML::NN_forward(const double * const * prho, ModulePW::PW_Basis *pw_rho
328328

329329
void KEDF_ML::loadVector(std::string filename, std::vector<double> &data)
330330
{
331-
std::vector<long unsigned int> cshape = {(long unsigned) this->cal_tool->nx};
332-
bool fortran_order = false;
333-
npy::LoadArrayFromNumpy(filename, cshape, fortran_order, data);
331+
npy::npy_data<double> d = npy::read_npy<double>(filename);
332+
data = d.data;
333+
// ========== For old version of npy.hpp ==========
334+
// std::vector<long unsigned int> cshape = {(long unsigned) this->cal_tool->nx};
335+
// bool fortran_order = false;
336+
// npy::LoadArrayFromNumpy(filename, cshape, fortran_order, data);
334337
}
335338

336339
void KEDF_ML::dumpVector(std::string filename, const std::vector<double> &data)
337340
{
338-
const long unsigned cshape[] = {(long unsigned) this->cal_tool->nx}; // shape
339-
npy::SaveArrayAsNumpy(filename, false, 1, cshape, data);
341+
npy::npy_data_ptr<double> d;
342+
d.data_ptr = data.data();
343+
d.shape = {(long unsigned) this->cal_tool->nx};
344+
d.fortran_order = false; // optional
345+
npy::write_npy(filename, d);
346+
// ========== For old version of npy.hpp ==========
347+
// const long unsigned cshape[] = {(long unsigned) this->cal_tool->nx}; // shape
348+
// npy::SaveArrayAsNumpy(filename, false, 1, cshape, data);
340349
}
341350

342351
/**

0 commit comments

Comments
 (0)