@@ -47,18 +47,11 @@ IntegerVector calc_mismatch_size(const RawMatrix& x, const RawMatrix& y) {
4747
4848// [[Rcpp::export]]
4949IntegerVector mismatch_size (const RawMatrix& x, const RawMatrix& y) {
50- if (x.rows () != y.rows ()) {
51- Rcpp::stop (" `x` and `y` differ in number of splits." );
52- }
53- if (!x.hasAttribute (" nTip" )) {
54- Rcpp::stop (" `x` lacks nTip attribute" );
55- }
56- if (!y.hasAttribute (" nTip" )) {
57- Rcpp::stop (" `y` lacks nTip attribute" );
58- }
59- if (static_cast <int >(x.attr (" nTip" )) != static_cast <int >(y.attr (" nTip" ))) {
60- Rcpp::stop (" `x` and `y` differ in `nTip`" );
61- }
50+ ASSERT (x.rows () == y.rows () && " `x` and `y` differ in number of splits." );
51+ ASSERT (x.hasAttribute (" nTip" ) && " `x` lacks nTip attribute" );
52+ ASSERT (y.hasAttribute (" nTip" ) && " `y` lacks nTip attribute" );
53+ ASSERT (static_cast <int >(x.attr (" nTip" )) == static_cast <int >(y.attr (" nTip" ))
54+ && " `x` and `y` differ in `nTip`" );
6255 return calc_mismatch_size (x, y);
6356}
6457
@@ -102,25 +95,17 @@ IntegerVector calc_confusion(const RawMatrix &x, const RawMatrix &y) {
10295
10396// [[Rcpp::export]]
10497IntegerVector confusion (const RawMatrix& x, const RawMatrix& y) {
105- if (x.rows () != y.rows ()) {
106- Rcpp::stop (" Input splits must contain same number of splits." );
107- }
108- if (!x.hasAttribute (" nTip" )) {
109- Rcpp::stop (" `x` lacks nTip attribute" );
110- }
111- if (!y.hasAttribute (" nTip" )) {
112- Rcpp::stop (" `y` lacks nTip attribute" );
113- }
114- if (static_cast <int >(x.attr (" nTip" )) != static_cast <int >(y.attr (" nTip" ))) {
115- Rcpp::stop (" `x` and `y` differ in `nTip`" );
116- }
98+ ASSERT (x.rows () == y.rows () && " Input splits must contain same number of splits." );
99+ ASSERT (x.hasAttribute (" nTip" ) && " `x` lacks nTip attribute" );
100+ ASSERT (y.hasAttribute (" nTip" ) && " `y` lacks nTip attribute" );
101+ ASSERT (static_cast <int >(x.attr (" nTip" )) == static_cast <int >(y.attr (" nTip" ))
102+ && " `x` and `y` differ in `nTip`" );
117103 return calc_confusion (x, y);
118104}
119105
120106IntegerMatrix reverse (const IntegerMatrix x) {
121- if (double (x.nrow ()) > double (std::numeric_limits<intx>::max ())) {
122- Rcpp::stop (" This many edges are not (yet) supported." );
123- }
107+ ASSERT (double (x.nrow ()) <= double (std::numeric_limits<intx>::max ())
108+ && " This many edges are not (yet) supported." );
124109 const intx n_edge = intx (x.nrow ());
125110 ASSERT (n_edge % 2 == 0 ); // Tree is binary
126111 IntegerMatrix ret (n_edge, 2 );
0 commit comments