Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak some miscellaneous things to pass R CMD check on all platforms #1

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions inst/include/config.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#pragma once
#include <Rcpp.h>
#include <omp.h>

#ifdef _OPENMP
#include <omp.h>
#else
#define omp_get_num_threads() 1
#define omp_get_thread_num() 0
#define omp_get_max_threads() 1
#define omp_get_thread_limit() 1
#define omp_get_num_procs() 1
#endif

#include <Rcpp.h>
#include <cmath>
#include <cstdlib>
#include <map>
Expand Down
4 changes: 2 additions & 2 deletions inst/include/random.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once
#include <Rcpp.h>
#include <omp.h>

#include <trng/yarn2.hpp>

#include "config.h"

/**
* @brief Singleton class managing a parallel RNG engine for
* the entire package.
Expand Down
3 changes: 1 addition & 2 deletions src/mod_mack.f90
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ function mack_pairs_boot(trngl, n_boot, n_sim, pgb) result(reserve)
type(c_ptr), intent(in), value :: pgb

real(c_double) :: reserve(n_boot * n_sim)
integer :: i, j, k, i_diag, i_boot, i_sim, i_thread, n_rows, n_obs
integer :: i, j, k, i_diag, i_boot, i_sim, n_rows, n_obs
real(c_double) :: mean, sd
real(c_double) :: triangle_sim(trngl%n_dev, trngl%n_dev)
integer :: status
Expand All @@ -256,7 +256,6 @@ function mack_pairs_boot(trngl, n_boot, n_sim, pgb) result(reserve)
logical :: show_progress

show_progress = c_associated(pgb)
i_thread = omp_get_thread_num()

i_boot = 1
main_loop: do while (i_boot <= n_boot)
Expand Down
6 changes: 6 additions & 0 deletions src/odp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ Rcpp::List odpSim(arma::mat triangle, options::SimType sim_type, int n_boot,
reserves.colptr(k), pgb);
break;
}
case options::PAIRS:
break;
}
}
}
Expand Down Expand Up @@ -239,6 +241,8 @@ Rcpp::List odpSim(arma::mat triangle, options::SimType sim_type, int n_boot,
reserves.colptr(i_diag), pgb);
break;
}
case options::PAIRS:
break;
}
}
}
Expand Down Expand Up @@ -295,6 +299,8 @@ Rcpp::List odpSim(arma::mat triangle, options::SimType sim_type, int n_boot,
reserves.colptr(i), pgb);
break;
}
case options::PAIRS:
break;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pgb.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <RcppArmadillo.h>
#include <omp.h>
#include "config.h"

#include <cmath>
#include <progress.hpp>
Expand Down
4 changes: 2 additions & 2 deletions src/random.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "random.h"

#include <Rcpp.h>
#include <omp.h>

#include <boost/math/distributions/poisson.hpp>
#include <trng/gamma_dist.hpp>
#include <trng/normal_dist.hpp>
#include <trng/poisson_dist.hpp>
#include <trng/uniform01_dist.hpp>

#include "config.h"

extern "C" {
double rnorm(double mean, double sd);
double rgamma(double shape, double scale);
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-boot_res.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ test_that("bootstrap plot works with correct output", {
announce_snapshot_file(name = "boot_multiple.png")
skip_on_ci()
skip_on_os("windows")
skip_on_os("mac")

res <- withr::with_seed(
42,
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-calendar.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ test_that("calendar sim plot works with correct output", {
announce_snapshot_file(name = "sim_calendar.png")
skip_on_ci()
skip_on_os("windows")
skip_on_os("mac")

withr::local_seed(42)
restore <- getTrnglSeed()
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-origin.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ test_that("origin sim plot works with correct output", {
announce_snapshot_file(name = "sim_origin.png")
skip_on_ci()
skip_on_os("windows")
skip_on_os("mac")

withr::local_seed(42)
restore <- getTrnglSeed()
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-single.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ test_that("single sim plot works with correct output", {
announce_snapshot_file(name = "sim_single.png")
skip_on_ci()
skip_on_os("windows")
skip_on_os("mac")

withr::local_seed(42)
restore <- getTrnglSeed()
Expand Down