diff --git a/test/test_utils/AllUtils.jl b/test/test_utils/AllUtils.jl deleted file mode 100644 index 4ca57d838..000000000 --- a/test/test_utils/AllUtils.jl +++ /dev/null @@ -1,7 +0,0 @@ -# Import utility functions and reused models. -include("staging.jl") -include("numerical_tests.jl") -include("ad_utils.jl") -include("models.jl") -include("random_measure_utils.jl") -include("testing_functions.jl") diff --git a/test/test_utils/random_measure_utils.jl b/test/test_utils/random_measure_utils.jl deleted file mode 100644 index 63c84c11a..000000000 --- a/test/test_utils/random_measure_utils.jl +++ /dev/null @@ -1,34 +0,0 @@ -function compute_log_joint(observations, partition, tau0, tau1, sigma, theta) - n = length(observations) - k = length(partition) - prob = k*log(sigma) + lgamma(theta) + lgamma(theta/sigma + k) - lgamma(theta/sigma) - lgamma(theta + n) - for cluster in partition - prob += lgamma(length(cluster) - sigma) - lgamma(1 - sigma) - prob += compute_log_conditional_observations(observations, cluster, tau0, tau1) - end - prob -end - -function compute_log_conditional_observations(observations, cluster, tau0, tau1) - nl = length(cluster) - prob = (nl/2)*log(tau1) - (nl/2)*log(2*pi) + 0.5*log(tau0) + 0.5*log(tau0+nl) - prob += -tau1/2*(sum(observations)) + 0.5*(tau0*mu_0+tau1*sum(observations[cluster]))^2/(tau0+nl*tau1) - prob -end - -# Test of similarity between distributions -function correct_posterior(empirical_probs, data, partitions, τ0, τ1, σ, θ) - true_log_probs = map(p -> compute_log_joint(data, p, τ0, τ1, σ, θ), partitions) - true_probs = exp.(true_log_probs) - true_probs /= sum(true_probs) - - empirical_probs /= sum(empirical_probs) - - # compare distribitions - # L2 - L2 = sum((empirical_probs - true_probs).^2) - - # Discrepancy - discr = maximum(abs.(empirical_probs - true_probs)) - return L2, discr -end diff --git a/test/test_utils/staging.jl b/test/test_utils/staging.jl deleted file mode 100644 index 15d5853d0..000000000 --- a/test/test_utils/staging.jl +++ /dev/null @@ -1,52 +0,0 @@ -function get_stage() - # Appveyor uses "True" for non-Ubuntu images. - if get(ENV, "APPVEYOR", "") == "True" || get(ENV, "APPVEYOR", "") == "true" - return "nonnumeric" - end - - # Handle Travis and Github Actions specially. - if get(ENV, "TRAVIS", "") == "true" || get(ENV, "GITHUB_ACTIONS", "") == "true" - if "STAGE" in keys(ENV) - return ENV["STAGE"] - else - return "all" - end - end - - return "all" -end - -function do_test(stage_str) - stg = get_stage() - - # If the tests are being run by Appveyor, don't run - # any numerical tests. - if stg == "nonnumeric" - if stage_str == "numerical" - return false - else - return true - end - end - - # Otherwise run the regular testing procedure. - if stg == "all" || stg == stage_str - return true - end - - return false -end - -macro stage_testset(stage_string::String, args...) - if do_test(stage_string) - return esc(:(@testset($(args...)))) - end -end - -macro numerical_testset(args...) - esc(:(@stage_testset "numerical" $(args...))) -end - -macro turing_testset(args...) - esc(:(@stage_testset "test" $(args...))) -end