From fa45524053c8bf1b0c69a6c3645fef97f73f86af Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Fri, 25 Sep 2015 16:28:40 -0400 Subject: [PATCH] Handle empty datasets. --- .../core/tree/binary_space_tree/binary_space_tree_impl.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp b/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp index 92b15927fb..f75070ea4a 100644 --- a/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp +++ b/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp @@ -586,7 +586,8 @@ void BinarySpaceTree:: SplitType, MatType>& splitter) { // We need to expand the bounds of this node properly. - bound |= dataset->cols(begin, begin + count - 1); + if (count > 0) + bound |= dataset->cols(begin, begin + count - 1); // Calculate the furthest descendant distance. furthestDescendantDistance = 0.5 * bound.Diameter(); @@ -643,7 +644,8 @@ SplitNode(std::vector& oldFromNew, { // This should be a single function for Bound. // We need to expand the bounds of this node properly. - bound |= dataset->cols(begin, begin + count - 1); + if (count > 0) + bound |= dataset->cols(begin, begin + count - 1); // Calculate the furthest descendant distance. furthestDescendantDistance = 0.5 * bound.Diameter();