[mlpack-git] [mlpack/mlpack] add cli executable for data_split (#650)

Ryan Curtin notifications at github.com
Wed Jun 1 09:57:19 EDT 2016


> @@ -41,6 +41,22 @@ void CompareData(const mat& inputData,
>    }
>  }
>  
> +void CheckMatEqual(const mat& inputData,
> +                   const mat& compareData)
> +{
> +  const mat& sortedInput = arma::sort(inputData, "ascend", 1);
> +  const mat& sortedCompare = arma::sort(compareData, "ascend", 1);
> +  for (size_t i = 0; i < sortedInput.n_cols; ++i)
> +  {
> +    const mat& lhsCol = sortedInput.col(i);
> +    const mat& rhsCol = sortedCompare.col(i);
> +    for (size_t j = 0; j < lhsCol.n_rows; ++j)
> +    {
> +      BOOST_REQUIRE_CLOSE(lhsCol(j), rhsCol(j), 1e-5);

This can fail for very small values, I like to use

```
if (std::abs(rhsCol(j)) < 1e-5)
  BOOST_REQUIRE_SMALL(lhsCol(j), 1e-5);
else
  BOOST_REQUIRE_CLOSE(lhsCol(j), rhsCol(j), 1e-5);
```

This is a nice utility function that we could probably use, though.  Actually now that I am thinking about it more... I wonder what would be necessary for us to be able to write `BOOST_REQUIRE_CLOSE(lhs, rhs, 1e-5)` and get the comparison here?  I dunno if that is worth taking the time to figure out though :)

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/650/files/8ad3b900bba6c8535ad94b5af31aaab1de0c64d1#r65364427
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160601/878f3c52/attachment.html>


More information about the mlpack-git mailing list