[mlpack-git] [mlpack/mlpack] backported ind2sub and sub2ind. (#683)

Ryan Curtin notifications at github.com
Tue Jun 7 14:18:39 EDT 2016


> +//#include <mlpack/methods/edge_boxes/structured_tree.hpp>
> +
> +#include <boost/test/unit_test.hpp>
> +#include "old_boost_test_definitions.hpp"
> +BOOST_AUTO_TEST_SUITE(ind2sub_test);
> +
> +/**
> + * This tests handles the case wherein only one class exists in the input
> + * labels.  It checks whether the only class supplied was the only class
> + * predicted.
> + */
> +BOOST_AUTO_TEST_CASE(ind2sub_test)
> +{
> +  arma::mat A = arma::randu(5,5);
> +  arma::uvec u = arma::ind2sub(arma::size(A), 3);
> +  u.print();

Hmm, this test doesn't actually test anything, do you think that we can test the output with `BOOST_REQUIRE_EQUAL`?  I don't know what the output values of u are supposed to be, but maybe something like

```
BOOST_REQUIRE_EQUAL(u(0), 0);
BOOST_REQUIRE_EQUAL(u(1), 3);
```

Technically I don't think we need to test Armadillo support since Armadillo should already be testing that, but, one nice thing this test *does* do is ensure that ind2sub() compiles correctly.  If you like, we can also add a very simple test like this for sub2ind().

---
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/683/files/1dfb208c7f4d652a2d194d8e5159e816cf629cb8#r66124752
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160607/92d0ddb2/attachment.html>


More information about the mlpack-git mailing list