Fix ShuffleData() implementation errors.

This commit is contained in:
Ryan Curtin
2017-10-04 15:57:09 -04:00
parent b3f9a45681
commit e81d7432f4
2 changed files with 5 additions and 3 deletions
+3 -1
View File
@@ -69,7 +69,9 @@ void ShuffleData(const MatType& inputPoints,
outputPoints = MatType(locations, values, inputPoints.n_rows,
inputPoints.n_cols, true);
outputLabels = inputLabels.cols(ordering);
outputLabels.set_size(inputLabels.n_elem);
for (size_t i = 0; i < inputLabels.n_elem; ++i)
outputLabels[ordering[i]] = inputLabels[i];
}
} // namespace math
+2 -2
View File
@@ -609,7 +609,7 @@ BOOST_AUTO_TEST_CASE(ShuffleTest)
arma::Row<size_t> counts(10, arma::fill::zeros);
for (size_t i = 0; i < 10; ++i)
{
BOOST_REQUIRE_EQUAL((size_t) outputData(0, i), labels[i]);
BOOST_REQUIRE_EQUAL((size_t) outputData(0, i), outputLabels[i]);
BOOST_REQUIRE_SMALL(outputData(1, i), 1e-5);
BOOST_REQUIRE_SMALL(outputData(2, i), 1e-5);
counts[labels[i]]++;
@@ -645,7 +645,7 @@ BOOST_AUTO_TEST_CASE(SparseShuffleTest)
arma::Row<size_t> counts(10, arma::fill::zeros);
for (size_t i = 0; i < 10; ++i)
{
BOOST_REQUIRE_EQUAL((size_t) outputData(0, i), labels[i]);
BOOST_REQUIRE_EQUAL((size_t) outputData(0, i), outputLabels[i]);
BOOST_REQUIRE_SMALL((double) outputData(1, i), 1e-5);
BOOST_REQUIRE_SMALL((double) outputData(2, i), 1e-5);
counts[labels[i]]++;