[mlpack-svn] r10351 - mlpack/trunk/src/mlpack/tests

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue Nov 22 14:18:33 EST 2011


Author: rcurtin
Date: 2011-11-22 14:18:32 -0500 (Tue, 22 Nov 2011)
New Revision: 10351

Modified:
   mlpack/trunk/src/mlpack/tests/distribution_test.cpp
   mlpack/trunk/src/mlpack/tests/gmm_test.cpp
   mlpack/trunk/src/mlpack/tests/hmm_test.cpp
   mlpack/trunk/src/mlpack/tests/tree_test.cpp
Log:
Don't use srand() in tests, so that the results are reproducible.


Modified: mlpack/trunk/src/mlpack/tests/distribution_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/distribution_test.cpp	2011-11-22 19:17:27 UTC (rev 10350)
+++ mlpack/trunk/src/mlpack/tests/distribution_test.cpp	2011-11-22 19:18:32 UTC (rev 10351)
@@ -193,7 +193,6 @@
  */
 BOOST_AUTO_TEST_CASE(GaussianDistributionRandomTest)
 {
-  srand(time(NULL));
   arma::vec mean("1.0 2.25");
   arma::mat cov("0.85 0.60;"
                 "0.60 1.45");

Modified: mlpack/trunk/src/mlpack/tests/gmm_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/gmm_test.cpp	2011-11-22 19:17:27 UTC (rev 10350)
+++ mlpack/trunk/src/mlpack/tests/gmm_test.cpp	2011-11-22 19:18:32 UTC (rev 10351)
@@ -125,9 +125,6 @@
  */
 BOOST_AUTO_TEST_CASE(GMMTrainEMOneGaussian)
 {
-  // Initialize random seed.
-  srand(time(NULL));
-
   for (size_t iterations = 0; iterations < 4; iterations++)
   {
     // Determine random covariance and mean.

Modified: mlpack/trunk/src/mlpack/tests/hmm_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/hmm_test.cpp	2011-11-22 19:17:27 UTC (rev 10350)
+++ mlpack/trunk/src/mlpack/tests/hmm_test.cpp	2011-11-22 19:18:32 UTC (rev 10351)
@@ -593,8 +593,6 @@
  */
 BOOST_AUTO_TEST_CASE(GaussianHMMTrainTest)
 {
-  srand(time(NULL));
-
   // Four emission Gaussians and three internal states.  The goal is to estimate
   // the transition matrix correctly, and each distribution correctly.
   std::vector<GaussianDistribution> emission;

Modified: mlpack/trunk/src/mlpack/tests/tree_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/tree_test.cpp	2011-11-22 19:17:27 UTC (rev 10350)
+++ mlpack/trunk/src/mlpack/tests/tree_test.cpp	2011-11-22 19:18:32 UTC (rev 10351)
@@ -342,8 +342,6 @@
  */
 BOOST_AUTO_TEST_CASE(HRectBoundRangeDistanceBound)
 {
-  srand(time(NULL));
-
   for (int i = 0; i < 50; i++)
   {
     size_t dim = rand() % 20;
@@ -395,8 +393,6 @@
  */
 BOOST_AUTO_TEST_CASE(HRectBoundRangeDistancePoint)
 {
-  srand(time(NULL));
-
   for (int i = 0; i < 20; i++)
   {
     size_t dim = rand() % 20;
@@ -942,9 +938,6 @@
   size_t max_runs = 10; // Ten total tests.
   size_t point_increments = 1000; // Range is from 2000 points to 11000.
 
-  // Generate the dataset.
-  srand(time(NULL));
-
   // Reset the leaf size as other tests have been naughty.
   // Also, a leaf size of 20 makes the test take too long.
   CLI::GetParam<int>("tree/leaf_size") = 20;




More information about the mlpack-svn mailing list