[mlpack] 131/207: Minor fixes in load_save_test.cpp

Barak A. Pearlmutter barak+git at pearlmutter.net
Thu Mar 23 17:53:47 UTC 2017


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch master
in repository mlpack.

commit 1cd3567705de74c50be60bc399e58a2fb125620a
Author: Lakshya Agrawal <zeeshan.lakshya at gmail.com>
Date:   Mon Mar 6 12:57:28 2017 +0530

    Minor fixes in load_save_test.cpp
---
 src/mlpack/core/data/load_impl.hpp  |  4 +---
 src/mlpack/tests/load_save_test.cpp | 40 ++++++++++++++++++++++++-------------
 2 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/src/mlpack/core/data/load_impl.hpp b/src/mlpack/core/data/load_impl.hpp
index 874f32f..1573883 100644
--- a/src/mlpack/core/data/load_impl.hpp
+++ b/src/mlpack/core/data/load_impl.hpp
@@ -320,9 +320,7 @@ bool Load(const std::string& filename,
   // We can't use the stream if the type is HDF5.
   bool success;
   if (loadType != arma::hdf5_binary)
-  {
-      success = matrix.load(stream, loadType);
-  }
+    success = matrix.load(stream, loadType);
   else
     success = matrix.load(filename, loadType);
 
diff --git a/src/mlpack/tests/load_save_test.cpp b/src/mlpack/tests/load_save_test.cpp
index 3267174..7ceba99 100644
--- a/src/mlpack/tests/load_save_test.cpp
+++ b/src/mlpack/tests/load_save_test.cpp
@@ -178,15 +178,27 @@ BOOST_AUTO_TEST_CASE(LoadTransposedCSVTest)
   // Remove the file.
   remove("test_file.csv");
 }
+
+/**
+ * The test LoadColVecCSVTest, LoadMatinColVec,
+ * LoadRowVecCSVTest need to run in DEBUG mode 
+ * else arma::colvec and arma::rowvec behave
+ * like arma::mat, that is you can also load 
+ * matrices into them if DEBUG mode is not on
+ * So to test whether Colvec and Rowvec load
+ * works, we need to turn on the debug mode
+ */
+
 /**
-  *Make sure ColVec can be loaded
-**/
+ * Make sure ColVec can be loaded
+ */
+#ifdef DEBUG
 BOOST_AUTO_TEST_CASE(LoadColVecCSVTest)
 {
   fstream f;
   f.open("test_file.csv", fstream::out);
 
-  for( int i = 0; i < 8; ++i)
+  for (int i = 0; i < 8; ++i)
     f << i << endl;
 
   f.close();
@@ -197,7 +209,7 @@ BOOST_AUTO_TEST_CASE(LoadColVecCSVTest)
   BOOST_REQUIRE_EQUAL(test.n_cols, 1);
   BOOST_REQUIRE_EQUAL(test.n_rows, 8);
 
-  for(size_t i = 0; i < 8; ++i)
+  for (size_t i = 0; i < 8; ++i)
     BOOST_REQUIRE_CLOSE(test[i], (double) (i), 1e-5);
 
   //Remove the file
@@ -205,11 +217,10 @@ BOOST_AUTO_TEST_CASE(LoadColVecCSVTest)
 }
 
 /**
-  *Make Sure Load throws Exception when trying
-  *to load a Matrix in ColVec 
-  *and RowVec
-**/
-#ifdef DEBUG
+ * Make Sure Load throws Exception when trying
+ * to load a Matrix in ColVec 
+ * and RowVec
+ */
 BOOST_AUTO_TEST_CASE(LoadMatinColVec)
 {
   fstream f;
@@ -232,16 +243,16 @@ BOOST_AUTO_TEST_CASE(LoadMatinColVec)
 
   remove("test_file.csv");
 }
-#endif
+
 /**
-  *Make sure RowVec can be loaded
-**/
+ * Make sure RowVec can be loaded
+ */
 BOOST_AUTO_TEST_CASE(LoadRowVecCSVTest)
 {
   fstream f;
   f.open("test_file.csv", fstream::out);
 
-  for(int i = 0 ; i < 7; ++i)
+  for (int i = 0 ; i < 7; ++i)
     f << i << ",";
   f << "7";
   f << endl;
@@ -254,11 +265,12 @@ BOOST_AUTO_TEST_CASE(LoadRowVecCSVTest)
   BOOST_REQUIRE_EQUAL(test.n_cols, 8);
   BOOST_REQUIRE_EQUAL(test.n_rows, 1);
 
-  for(size_t i = 0; i < 8 ; ++i)
+  for (size_t i = 0; i < 8 ; ++i)
     BOOST_REQUIRE_CLOSE(test[i], (double) (i) , 1e-5);
 
   remove("test_file.csv");
 }
+#endif
 
 /**
  * Make sure TSVs can be loaded in transposed form.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git



More information about the debian-science-commits mailing list