[mlpack] 90/207: I love when the error is in the test, not the algorithm.

Barak A. Pearlmutter barak+git at pearlmutter.net
Thu Mar 23 17:53:43 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 4b1afb354a38d80701e10385d1e64058573c833c
Author: Ryan Curtin <ryan at ratml.org>
Date:   Sat Feb 25 13:11:02 2017 -0500

    I love when the error is in the test, not the algorithm.
    
    In this case the matches array was simply being assembled wrong.
---
 src/mlpack/tests/dbscan_test.cpp | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/mlpack/tests/dbscan_test.cpp b/src/mlpack/tests/dbscan_test.cpp
index d9ab785..9edf279 100644
--- a/src/mlpack/tests/dbscan_test.cpp
+++ b/src/mlpack/tests/dbscan_test.cpp
@@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE(GaussiansTest)
   for (size_t i = 200; i < 300; ++i)
     points.col(i) = g3.Random();
 
-  DBSCAN<> d(1.0, 3);
+  DBSCAN<> d(2.0, 3);
 
   arma::Row<size_t> assignments;
   arma::mat centroids;
@@ -105,20 +105,22 @@ BOOST_AUTO_TEST_CASE(GaussiansTest)
   matches.fill(3);
   for (size_t j = 0; j < 3; ++j)
   {
-    if (arma::norm(g1.Mean() - centroids.col(j)) < 1.0)
-      matches(j) = 0;
-    else if (arma::norm(g2.Mean() - centroids.col(j)) < 1.0)
-      matches(j) = 1;
-    else if (arma::norm(g3.Mean() - centroids.col(j)) < 1.0)
-      matches(j) = 2;
-
-    BOOST_REQUIRE_NE(matches(j), 3);
+    if (arma::norm(g1.Mean() - centroids.col(j)) < 3.0)
+      matches(0) = j;
+    else if (arma::norm(g2.Mean() - centroids.col(j)) < 3.0)
+      matches(1) = j;
+    else if (arma::norm(g3.Mean() - centroids.col(j)) < 3.0)
+      matches(2) = j;
   }
 
   BOOST_REQUIRE_NE(matches(0), matches(1));
   BOOST_REQUIRE_NE(matches(1), matches(2));
   BOOST_REQUIRE_NE(matches(2), matches(0));
 
+  BOOST_REQUIRE_NE(matches(0), 3);
+  BOOST_REQUIRE_NE(matches(1), 3);
+  BOOST_REQUIRE_NE(matches(2), 3);
+
   for (size_t i = 0; i < 100; ++i)
   {
     // Each point should either be noise or in cluster matches(0).

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