[mlpack-git] master: Minor style fixes. (6a70cfc)
gitdub at mlpack.org
gitdub at mlpack.org
Mon Apr 4 22:45:13 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/fb75f38b6a968c928de229c5f4b8c25736e34e84...e14c246389e7cd3a910933446ae2b74333ca377b
>---------------------------------------------------------------
commit 6a70cfcf8fea83b799f7ca8767761f577fe1aecc
Author: Ryan Curtin <ryan at ratml.org>
Date: Mon Apr 4 22:45:13 2016 -0400
Minor style fixes.
>---------------------------------------------------------------
6a70cfcf8fea83b799f7ca8767761f577fe1aecc
src/mlpack/tests/cosine_tree_test.cpp | 36 ++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/src/mlpack/tests/cosine_tree_test.cpp b/src/mlpack/tests/cosine_tree_test.cpp
index 627a8d2..925684f 100644
--- a/src/mlpack/tests/cosine_tree_test.cpp
+++ b/src/mlpack/tests/cosine_tree_test.cpp
@@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(CosineNodeCosineSplit)
// Initialize constants required for the test.
const size_t numRows = 500;
const size_t numCols = 1000;
- // Calculation accuracy
+ // Calculation accuracy.
const double precision = 1e-15;
// Make a random dataset and the root object.
@@ -106,50 +106,52 @@ BOOST_AUTO_TEST_CASE(CosineNodeCosineSplit)
cosines(k) = arma::norm_dot(data.col(rightIndices[j]), splitPoint);
// Check if the columns assigned to the children agree with the splitting
- // condition.
- // Due to miscalculations cosineMax calculated at CosineNodeSplit
- // may differ from cosineMax below
+ // condition. Due to miscalculations cosineMax calculated by
+ // CosineNodeSplit may differ from cosineMax below, so we have to handle
+ // minor differences.
double cosineMax = arma::max(cosines % (cosines < 1.0 + precision));
double cosineMin = arma::min(cosines);
// If max(cosines) is close to 1.0 cosineMax and cosineMax2 may
- // differ significantly
+ // differ significantly.
double cosineMax2 = arma::max(cosines % (cosines < 1.0 - precision));
- if(std::fabs(cosineMax - cosineMax2) < precision)
+ if (std::fabs(cosineMax - cosineMax2) < precision)
{
- // Check with some precision
+ // Check with some precision.
for (i = 0; i < leftIndices.size(); i++)
- BOOST_REQUIRE_LT(cosineMax - cosines(i), cosines(i) - cosineMin + precision);
+ BOOST_REQUIRE_LT(cosineMax - cosines(i),
+ cosines(i) - cosineMin + precision);
for (j = 0, k = i; j < rightIndices.size(); j++, k++)
- BOOST_REQUIRE_GT(cosineMax - cosines(k), cosines(k) - cosineMin - precision);
+ BOOST_REQUIRE_GT(cosineMax - cosines(k),
+ cosines(k) - cosineMin - precision);
}
else
{
size_t numMax1Errors = 0;
size_t numMax2Errors = 0;
- // Find errors for cosineMax
+ // Find errors for cosineMax.
for (i = 0; i < leftIndices.size(); i++)
- if(cosineMax - cosines(i) >= cosines(i) - cosineMin + precision)
+ if (cosineMax - cosines(i) >= cosines(i) - cosineMin + precision)
numMax1Errors++;
for (j = 0, k = i; j < rightIndices.size(); j++, k++)
- if(cosineMax - cosines(k) <= cosines(k) - cosineMin - precision)
+ if (cosineMax - cosines(k) <= cosines(k) - cosineMin - precision)
numMax1Errors++;
- // Find errors for cosineMax2
+ // Find errors for cosineMax2.
for (i = 0; i < leftIndices.size(); i++)
- if(cosineMax2 - cosines(i) >= cosines(i) - cosineMin + precision)
+ if (cosineMax2 - cosines(i) >= cosines(i) - cosineMin + precision)
numMax2Errors++;
for (j = 0, k = i; j < rightIndices.size(); j++, k++)
- if(cosineMax2 - cosines(k) <= cosines(k) - cosineMin - precision)
+ if (cosineMax2 - cosines(k) <= cosines(k) - cosineMin - precision)
numMax2Errors++;
- // One of the maximum cosine values should be correct
- BOOST_REQUIRE_EQUAL(std::min(numMax1Errors,numMax2Errors),0);
+ // One of the maximum cosine values should be correct
+ BOOST_REQUIRE_EQUAL(std::min(numMax1Errors, numMax2Errors), 0);
}
}
}
More information about the mlpack-git
mailing list