[mlpack] 04/04: Rewrite NMFALSTest so that random failures should be less likely.

Barak A. Pearlmutter barak+git at cs.nuim.ie
Fri May 9 08:38:36 UTC 2014


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

bap pushed a commit to branch svn-trunk
in repository mlpack.

commit 8c20ea8559338a300ec8315700cdf613ac4b83ad
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Sat Apr 26 12:40:03 2014 +0000

    Rewrite NMFALSTest so that random failures should be less likely.
    
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16468 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 src/mlpack/tests/nmf_test.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mlpack/tests/nmf_test.cpp b/src/mlpack/tests/nmf_test.cpp
index 6e5f188..30f0720 100644
--- a/src/mlpack/tests/nmf_test.cpp
+++ b/src/mlpack/tests/nmf_test.cpp
@@ -102,11 +102,13 @@ BOOST_AUTO_TEST_CASE(NMFALSTest)
       HAlternatingLeastSquaresRule> nmf(50000, 1e-15);
   nmf.Apply(v, r, w, h);
 
-  mat wh = w * h;
+  const mat wh = w * h;
 
-  for (size_t row = 0; row < 20; row++)
-    for (size_t col = 0; col < 20; col++)
-      BOOST_REQUIRE_CLOSE(v(row, col), wh(row, col), 18.0);
+  const double error = arma::accu(arma::abs(v - wh)) / arma::accu(v);
+
+  // Most runs seem to produce error between 0.01 and 0.03.
+  // This is a randomized test, so we don't really have guarantees.
+  BOOST_REQUIRE_SMALL(error, 0.04);
 }
 
 /**

-- 
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