python module pass basic test

This commit is contained in:
tqchen
2014-08-17 18:43:25 -07:00
parent af100dd869
commit 301685e0a4
7 changed files with 170 additions and 121 deletions

View File

@@ -15,7 +15,12 @@ DataMatrix* LoadDataMatrix(const char *fname, bool silent, bool savebuffer) {
}
void SaveDataMatrix(const DataMatrix &dmat, const char *fname, bool silent) {
utils::Error("not implemented");
if (dmat.magic == DMatrixSimple::kMagic){
const DMatrixSimple *p_dmat = static_cast<const DMatrixSimple*>(&dmat);
p_dmat->SaveBinary(fname, silent);
} else {
utils::Error("not implemented");
}
}
} // namespace io

View File

@@ -148,7 +148,7 @@ class DMatrixSimple : public DataMatrix {
* \param fname name of binary data
* \param silent whether print information or not
*/
inline void SaveBinary(const char* fname, bool silent = false) {
inline void SaveBinary(const char* fname, bool silent = false) const {
utils::FileStream fs(utils::FopenCheck(fname, "wb"));
int magic = kMagic;
fs.Write(&magic, sizeof(magic));