Skip to content

Commit 1e456e8

Browse files
test sum(complex vector) and quiet when calling setRefClass
1 parent 92775bd commit 1e456e8

5 files changed

Lines changed: 31 additions & 3 deletions

File tree

R/RcppExports.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,10 @@ runit_sum <- function(xx) {
11571157
.Call('RcppTest_runit_sum', PACKAGE = 'RcppTest', xx)
11581158
}
11591159

1160+
runit_sum_cplx <- function(xx) {
1161+
.Call('RcppTest_runit_sum_cplx', PACKAGE = 'RcppTest', xx)
1162+
}
1163+
11601164
runit_cumsum <- function(xx) {
11611165
.Call('RcppTest_runit_cumsum', PACKAGE = 'RcppTest', xx)
11621166
}

src/RcppExports.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4449,6 +4449,22 @@ BEGIN_RCPP
44494449
return __sexp_result;
44504450
END_RCPP
44514451
}
4452+
// runit_sum_cplx
4453+
Rcomplex runit_sum_cplx(ComplexVector xx);
4454+
extern "C" SEXP RcppTest_runit_sum_cplx(SEXP xxSEXP) {
4455+
BEGIN_RCPP
4456+
SEXP __sexp_result;
4457+
{
4458+
Rcpp::RNGScope __rngScope;
4459+
Rcpp::traits::input_parameter< ComplexVector >::type xx(xxSEXP );
4460+
Rcomplex __result = runit_sum_cplx(xx);
4461+
PROTECT(__sexp_result = Rcpp::wrap(__result));
4462+
}
4463+
UNPROTECT(1);
4464+
return __sexp_result;
4465+
END_RCPP
4466+
}
4467+
44524468
// runit_cumsum
44534469
NumericVector runit_cumsum(NumericVector xx);
44544470
extern "C" SEXP RcppTest_runit_cumsum(SEXP xxSEXP) {

src/sugar.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@ List runit_beta( NumericVector nn, NumericVector kk){
470470
_["VP"] = beta(nn, 5.0 )
471471
) ;
472472
}
473-
474473
// [[Rcpp::export]]
475474
List runit_psigamma( NumericVector nn, NumericVector kk){
476475
return List::create(
@@ -502,6 +501,11 @@ double runit_sum( NumericVector xx){
502501
return sum( xx ) ;
503502
}
504503

504+
// [[Rcpp::export]]
505+
Rcomplex runit_sum_cplx( ComplexVector xx){
506+
return sum( xx ) ;
507+
}
508+
505509
// [[Rcpp::export]]
506510
NumericVector runit_cumsum( NumericVector xx ){
507511
NumericVector res = cumsum( xx ) ;

tests/testthat/test-misc.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ test_that( "StrechyList correctly builds pairlists", {
7474
})
7575

7676
test_that( "Reference works", {
77-
Instrument <- setRefClass(
77+
Instrument <- suppressWarnings(setRefClass(
7878
Class="Instrument",
7979
fields=list("id"="character", "description"="character"),
8080
where = environment()
81-
)
81+
))
8282
Instrument$accessors(c("id", "description"))
8383

8484
instrument <- Instrument$new(id="AAPL", description="Apple")

tests/testthat/test-sugar.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,10 @@ test_that("sugar sum functions work", {
436436
expect_equal( runit_cumsum(x), cumsum(x) )
437437
x[4] <- NA
438438
expect_equal( runit_cumsum(x), cumsum(x) )
439+
440+
y <- rnorm(10) + rnorm(10)*1i
441+
expect_equal( runit_sum_cplx(y), sum(y) )
442+
439443
})
440444

441445
test_that( "rounding functions work", {

0 commit comments

Comments
 (0)