[mlpack-svn] r13848 - mlpack/trunk/src/mlpack/tests
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Nov 7 15:21:03 EST 2012
Author: rcurtin
Date: 2012-11-07 15:21:02 -0500 (Wed, 07 Nov 2012)
New Revision: 13848
Modified:
mlpack/trunk/src/mlpack/tests/kmeans_test.cpp
mlpack/trunk/src/mlpack/tests/tree_test.cpp
Log:
Only do sparse tests if sparse matrix support exists.
Modified: mlpack/trunk/src/mlpack/tests/kmeans_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/kmeans_test.cpp 2012-11-06 03:24:10 UTC (rev 13847)
+++ mlpack/trunk/src/mlpack/tests/kmeans_test.cpp 2012-11-07 20:21:02 UTC (rev 13848)
@@ -206,9 +206,10 @@
BOOST_REQUIRE_LT(assignments[i], 18);
}
+#ifdef ARMA_HAS_SPMAT
/**
* Make sure sparse k-means works okay.
- *
+ */
BOOST_AUTO_TEST_CASE(SparseKMeansTest)
{
// Huge dimensionality, few points.
@@ -248,6 +249,6 @@
BOOST_REQUIRE_EQUAL(assignments[10], clusterTwo);
BOOST_REQUIRE_EQUAL(assignments[11], clusterTwo);
}
-*/
+#endif // ARMA_HAS_SPMAT
BOOST_AUTO_TEST_SUITE_END();
Modified: mlpack/trunk/src/mlpack/tests/tree_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/tree_test.cpp 2012-11-06 03:24:10 UTC (rev 13847)
+++ mlpack/trunk/src/mlpack/tests/tree_test.cpp 2012-11-07 20:21:02 UTC (rev 13848)
@@ -1491,8 +1491,8 @@
}
// Forward declaration of methods we need for the next test.
-template<typename TreeType>
-bool CheckPointBounds(TreeType* node, const arma::mat& data);
+template<typename TreeType, typename MatType>
+bool CheckPointBounds(TreeType* node, const MatType& data);
template<typename TreeType>
void GenerateVectorOfTree(TreeType* node,
@@ -1594,8 +1594,8 @@
}
// Recursively checks that each node contains all points that it claims to have.
-template<typename TreeType>
-bool CheckPointBounds(TreeType* node, const arma::mat& data)
+template<typename TreeType, typename MatType>
+bool CheckPointBounds(TreeType* node, const MatType& data)
{
if (node == NULL) // We have passed a leaf node.
return true;
@@ -1656,6 +1656,7 @@
return;
}
+#ifdef ARMA_HAS_SPMAT
/**
* Exhaustive sparse kd-tree test based on #125.
*
@@ -1692,7 +1693,7 @@
std::vector<size_t> oldToNew;
// Generate data.
- dataset.randu();
+ dataset.sprandu(dimensions, size, 0.1);
datacopy = dataset; // Save a copy.
// Build the tree itself.
@@ -1744,6 +1745,7 @@
// Check the tree depth.
BOOST_REQUIRE_EQUAL(root.TreeDepth(), 7);
}
+#endif // ARMA_HAS_SPMAT
template<typename TreeType>
void RecurseTreeCountLeaves(const TreeType& node, arma::vec& counts)
More information about the mlpack-svn
mailing list