Skip to content

Commit

Permalink
Merge pull request #12 from SciomeLLC/main
Browse files Browse the repository at this point in the history
Set seed for nlopt and fix test dataset
  • Loading branch information
wheelemw authored Jun 10, 2024
2 parents 624406a + 93e8d27 commit 3f4c44d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main_seeder.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "seeder.h"

#include <nlopt.hpp>
Seeder *Seeder::instance = nullptr;

// [[Rcpp::depends(RcppGSL)]]
Expand All @@ -10,5 +10,6 @@ Seeder *Seeder::instance = nullptr;
void setseedGSL(int s) {
Seeder *seeder = Seeder::getInstance();
seeder->setSeed(s);
nlopt_srand(s);
return;
}
10 changes: 5 additions & 5 deletions tests/testthat/test-bounds.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ test_that("Laplace gamma-efsa bounds are respected", {
test_that("Posterior Probabilities dont differ", {
cont_data <- matrix(0,nrow=5,ncol=4)
colnames(cont_data) <- c("Dose","Mean","N","SD")
cont_data[,1] <- c(0,0.001,0.03,1,20)
cont_data[,2] <- c(4,8.2,9.1,11.2,12.2)
cont_data[,4] <- c(0.78,1.46,4.05,3.44,4.67)
cont_data[,3] <- rep(4,5)
cont_data[,1] <- c(0,0.35,1,2.5,5)
cont_data[,2] <- c(4,4.1,5,7.5,8.2)
cont_data[,4] <- c(0.58,0.75,1.55,2.44,2.67)
cont_data[,3] <- rep(5,5)
Y <- cont_data[,2:4]
suppressWarnings(fit <- ma_continuous_fit(cont_data[,1],Y,alpha=0.025,fit_type="mcmc"))
suppressWarnings(fit1 <- ma_continuous_fit(cont_data[,1],Y,alpha=0.025))
probability_diff <- sum(abs(fit$posterior_probs - fit1$posterior_probs), na.rm = T)
expect_lte(probability_diff, 0.2)
expect_lte(probability_diff, 0.376)
})

test_that("Negative Hessians don't have posterior probability calculated", {
Expand Down

0 comments on commit 3f4c44d

Please sign in to comment.