[mlpack] 182/324: more tests. Really silly bug fix.
Barak A. Pearlmutter
barak+git at cs.nuim.ie
Sun Aug 17 08:22:08 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 e37b73eeccde29802d749e278a26a6d2e1e93d3c
Author: andrewmw94 <andrewmw94 at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date: Mon Jul 14 14:53:20 2014 +0000
more tests. Really silly bug fix.
git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16821 9d5b8971-822b-0410-80eb-d18c1038ef23
---
.../tree/rectangle_tree/rectangle_tree_impl.hpp | 8 +++++---
src/mlpack/tests/rectangle_tree_test.cpp | 23 ++++++++++++++++++++--
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
index 17bada5..adf1b89 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
@@ -169,12 +169,12 @@ typename MatType>
bool RectangleTree<SplitType, DescentType, StatisticType, MatType>::
DeletePoint(const size_t point)
{
-
if (numChildren == 0) {
for (size_t i = 0; i < count; i++) {
if (points[i] == point) {
localDataset->col(i) = localDataset->col(--count); // decrement count
points[i] = points[count];
+ std::cout << count << std::endl;
CondenseTree(dataset.col(point)); // This function will ensure that minFill is satisfied.
return true;
}
@@ -388,11 +388,13 @@ void RectangleTree<SplitType, DescentType, StatisticType, MatType>::CondenseTree
parent->ShrinkBoundForBound(bound); // We want to do this before reinserting points.
// Reinsert the points at the root node.
- RectangleTree<SplitType, DescentType, StatisticType, MatType>* root = this;
+ RectangleTree<SplitType, DescentType, StatisticType, MatType>* root = parent;
while (root->Parent() != NULL)
root = root->Parent();
- for (size_t j = 0; j < numChildren; j++)
+
+ for (size_t j = 0; j < count; j++) {
root->InsertPoint(points[j]);
+ }
parent->CondenseTree(point); // This will check the MinFill of the parent.
//Now it should be safe to delete this node.
diff --git a/src/mlpack/tests/rectangle_tree_test.cpp b/src/mlpack/tests/rectangle_tree_test.cpp
index 6331a68..47d046d 100644
--- a/src/mlpack/tests/rectangle_tree_test.cpp
+++ b/src/mlpack/tests/rectangle_tree_test.cpp
@@ -173,13 +173,32 @@ BOOST_AUTO_TEST_CASE(PointDeletion) {
arma::mat dataset;
dataset.randu(8, 1000); // 1000 points in 8 dimensions.
+ const int numIter = 50;
+
RectangleTree<tree::RTreeSplit<tree::RTreeDescentHeuristic, NeighborSearchStat<NearestNeighborSort>, arma::mat>,
tree::RTreeDescentHeuristic,
NeighborSearchStat<NearestNeighborSort>,
arma::mat> tree(dataset, 20, 6, 5, 2, 0);
- tree.DeletePoint(999);
- assert(tree.NumDescendants() == 999);
+ for(int i = 0; i < numIter; i++) {
+ tree.DeletePoint(i);
+ }
+ std::cout << tree.NumDescendants() << std::endl;
+ assert(tree.NumDescendants() == 1000-numIter);
+
+ mlpack::neighbor::NeighborSearch<NearestNeighborSort, metric::LMetric<2, true>,
+ RectangleTree<tree::RTreeSplit<tree::RTreeDescentHeuristic, NeighborSearchStat<NearestNeighborSort>, arma::mat>,
+ tree::RTreeDescentHeuristic,
+ NeighborSearchStat<NearestNeighborSort>,
+ arma::mat> > allknn1(&tree,
+ dataset, true);
+
+ arma::Mat<size_t> neighbors;
+ arma::mat distances;
+ allknn1.Search(5, neighbors, distances);
+ for(int i = 0; i < numIter; i++)
+ assert(distances.at(0, i) > 0);
+
}
BOOST_AUTO_TEST_CASE(SingleTreeTraverserTest)
--
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