From 9e574098d28143fcfe03b04a3543cea40d7d381b Mon Sep 17 00:00:00 2001 From: MikeJaredS <35892779+MikeJaredS@users.noreply.github.com> Date: Tue, 16 Feb 2021 14:47:54 +0200 Subject: [PATCH] test: minor update to test cases --- DESCRIPTION | 2 +- NEWS.md | 6 + cran-comments.md | 56 +-------- tests/testthat/test_hermite_estimator.R | 118 ++++++++--------- tests/testthat/test_hermite_estimator_bivar.R | 119 +++++++++--------- 5 files changed, 133 insertions(+), 168 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7ab9e50..ee3b92e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: hermiter Title: Efficient Sequential and Batch Estimation of Univariate and Bivariate Probability Density Functions and Cumulative Distribution Functions along with Quantiles (Univariate) and Spearman's Correlation (Bivariate) -Version: 2.0.2 +Version: 2.0.3 Authors@R: c( person("Michael","Stephanou",role=c("aut","cre"), email="michael.stephanou@gmail.com"), person("Melvin","Varughese",role="ctb")) diff --git a/NEWS.md b/NEWS.md index cf1566d..2798d5b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# hermiter v2.0.3 + +## Minor improvements and bug fixes + +* Minor update to test cases. + # hermiter v2.0.2 ## Breaking changes diff --git a/cran-comments.md b/cran-comments.md index d0d94b9..c9d09bf 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,65 +1,17 @@ -# hermiter v2.0.2 +# hermiter v2.0.3 -Fixed ASAN issues picked up with clang. Updated the test environments as -listed below. This is a re-submission. - -# hermiter v2.0.1 - -Fixed minor issues in c++ source code causing the build to fail on Solaris -along with valgrind issues. Updated the test environments as listed below. -Added further test cases. This is a re-submission. - -# hermiter v2.0.0 - -This is a major update to include bivariate estimators. - -## Breaking changes - -* `get_coefficients` has been removed as it is redundant. -* `combine_hermite` has been renamed to `merge_hermite` for clarity. -* `combine_pair` has been renamed to `merge_pair` for clarity. -* `hermite_integral_val_quantile_adap` has been renamed to -`hermite_integral_val_upper` for clarity. - -## New features - -* Bivariate Hermite estimators have been added with methods for estimating -bivariate probability density functions and cumulative distribution functions -along with Spearman's rank correlation coefficients. -* The bivariate estimators include methods to batch update or sequentially -update. -* Methods are also provided to consistently merge bivariate hermite_estimators. -* Convenience methods have been added for calculating normalized Hermite -functions, along with upper, lower and full domain integrals of the -normalized Hermite functions. - -## Documentation improvements - -* The vignette `hermiter`, namely `vignette("hermiter")` has been extended to -included examples pertaining to the bivariate Hermite series based estimators. +Fixed ATLAS issue. ## Minor improvements and bug fixes -* The method for merging univariate Hermite series based estimators has been -improved, yielding greater accuracy when the hermite_estimators are -standardized. -* The method for estimating quantiles with the univariate Hermite series based -estimator has been improved and is now consistent with the estimator in the -literature. -* Added further error trapping and other minor enhancements. +* Minor update to test cases. ## Test environments * local R installation, Windows 10, R 4.0.3 -* local Linux Mint 20 installation, R 4.0.3 with valgrind -* rocker/r-devel-ubsan-clang docker image -* Ubuntu 16.04 (on travis-ci and r-hub), R 4.0.3 -* Debian Linux (r-hub) +* Ubuntu 20.04.1 LTS (r-hub), R 4.0.3 * Debian Linux, R-devel, GCC ASAN/UBSAN (r-hub) * Fedora Linux (r-hub) * Oracle Solaris 10, x86, 32 bit, R-release (r-hub) -* Oracle Solaris 10, x86, 32 bit, R-release, Oracle Developer Studio 12.6 (r-hub) -* macOS 10.13.6 High Sierra, R-release, brew (r-hub) -* macOS 10.13.6 High Sierra, R-release, CRAN's setup (r-hub) * win-builder (devel and release) ## R CMD check results diff --git a/tests/testthat/test_hermite_estimator.R b/tests/testthat/test_hermite_estimator.R index 8c36763..672cd81 100644 --- a/tests/testthat/test_hermite_estimator.R +++ b/tests/testthat/test_hermite_estimator.R @@ -2,6 +2,10 @@ context("hermite_estimator_univar") library(hermiter) library(magrittr) +get_eps <- function(){ + return(1e-3) +} + test_that("hermite_estimator constructor returns correct class", { hermite_est <- hermite_estimator(N = 10, standardize = TRUE) expect_is(hermite_est, "hermite_estimator_univar") @@ -144,16 +148,16 @@ test_that("batch updates of hermite_estimator work as expected", { hermite_est <- hermite_est %>% update_batch(test_observations) expect_equal(target_coeff_vec_standardized, hermite_est$coeff_vec, - tolerance = 1e-07) + tolerance = get_eps()) expect_equal(mean(test_observations), - hermite_est$running_mean,tolerance = 1e-06) + hermite_est$running_mean,tolerance = get_eps()) expect_equal(sd(test_observations),sqrt(hermite_est$running_variance / - (hermite_est$num_obs-1)),tolerance = 1e-06) + (hermite_est$num_obs-1)),tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, standardize = FALSE) hermite_est <- hermite_est %>% update_batch(test_observations) expect_equal(target_coeff_vec_unstandardized, hermite_est$coeff_vec, - tolerance = 1e-07) + tolerance = get_eps()) }) test_that("sequential updates of hermite_estimator work as expected", { @@ -224,7 +228,7 @@ test_that("sequential updates of hermite_estimator work as expected", { } expect_equal(target_coeff_vec_standardized, hermite_est$coeff_vec, - tolerance = 1e-07) + tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, standardize = FALSE) for (idx in seq_along(test_observations)) { @@ -233,7 +237,7 @@ test_that("sequential updates of hermite_estimator work as expected", { } expect_equal(target_coeff_vec_unstandardized, hermite_est$coeff_vec, - tolerance = 1e-07) + tolerance = get_eps()) }) test_that("sequential updates of exponentially weighted hermite_estimator @@ -309,7 +313,7 @@ test_that("sequential updates of exponentially weighted hermite_estimator } expect_equal(target_coeff_vec_standardized, hermite_est$coeff_vec, - tolerance = 1e-07) + tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, @@ -321,7 +325,7 @@ test_that("sequential updates of exponentially weighted hermite_estimator } expect_equal(target_coeff_vec_unstandardized, hermite_est$coeff_vec, - tolerance = 1e-07) + tolerance = get_eps()) }) test_that("hermite_estimators merge consistently", { @@ -371,10 +375,10 @@ test_that("hermite_estimators merge consistently", { update_batch(test_observations[21:30]) hermite_merged <- merge_hermite_univar(list(hermite_est_1, hermite_est_2, hermite_est_3)) - expect_equal(hermite_est, hermite_merged, tolerance = 1e-07) + expect_equal(hermite_est, hermite_merged, tolerance = get_eps()) hermite_merged <- merge_hermite(list(hermite_est_1, hermite_est_2, hermite_est_3)) - expect_equal(hermite_est, hermite_merged, tolerance = 1e-07) + expect_equal(hermite_est, hermite_merged, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, standardize = TRUE) %>% update_batch(test_observations) @@ -402,10 +406,10 @@ test_that("hermite_estimators merge consistently", { merge_hermite(list(hermite_est_1, hermite_est_2, hermite_est_3)) expect_equal(hermite_merged,hermite_merged_gen) expect_equal(hermite_est$running_mean, hermite_merged$running_mean, - tolerance = 1e-06) + tolerance = get_eps()) expect_equal(hermite_est$running_variance, hermite_merged$running_variance, - tolerance = 1e-06) - expect_equal(hermite_merged$num_obs,30, tolerance = 1e-06) + tolerance = get_eps()) + expect_equal(hermite_merged$num_obs,30, tolerance = get_eps()) target_coeffs <- c( 0.507692830456503, @@ -421,11 +425,7 @@ test_that("hermite_estimators merge consistently", { -0.117430497748064 ) expect_equal(hermite_merged$coeff_vec, target_coeffs, - tolerance = 1e-06) - expect_equal(hermite_merged$coeff_vec, hermite_est$coeff_vec, - tolerance = 5e-02) - - + tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, standardize = TRUE) %>% update_batch(test_observations) @@ -438,10 +438,10 @@ test_that("hermite_estimators merge consistently", { hermite_merged <- merge_pair(hermite_est_1, hermite_est_2) expect_equal(hermite_est$running_mean, hermite_merged$running_mean, - tolerance = 1e-06) + tolerance = get_eps()) expect_equal(hermite_est$running_variance, hermite_merged$running_variance, - tolerance = 1e-06) - expect_equal(hermite_merged$num_obs,30, tolerance = 1e-06) + tolerance = get_eps()) + expect_equal(hermite_merged$num_obs,30, tolerance = get_eps()) target_coeffs <- c( 0.507692794353622, @@ -457,9 +457,7 @@ test_that("hermite_estimators merge consistently", { -0.127949647659276 ) expect_equal(hermite_merged$coeff_vec, target_coeffs, - tolerance = 1e-06) - expect_equal(hermite_merged$coeff_vec, hermite_est$coeff_vec, - tolerance = 5e-02) + tolerance = get_eps()) hermite_est_1 <- hermite_estimator(N = 10, standardize = FALSE) %>% update_batch(test_observations[1:10]) @@ -529,7 +527,7 @@ test_that("probability density estimation works as expected", { 0.2005586, 0.1451746 ) - expect_equal(pdf_vals, target_pdf_vals_unstandardized, tolerance = 1e-07) + expect_equal(pdf_vals, target_pdf_vals_unstandardized, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, standardize = TRUE) %>% @@ -547,10 +545,10 @@ test_that("probability density estimation works as expected", { 0.1576933, 0.1306844 ) - expect_equal(pdf_vals, target_pdf_vals_standardized, tolerance = 1e-07) + expect_equal(pdf_vals, target_pdf_vals_standardized, tolerance = get_eps()) pdf_vals <- hermite_est %>% dens(x, clipped=T) - expect_equal(pdf_vals, target_pdf_vals_standardized, tolerance = 1e-07) + expect_equal(pdf_vals, target_pdf_vals_standardized, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, @@ -573,7 +571,7 @@ test_that("probability density estimation works as expected", { 0.1983007, 0.2352683 ) - expect_equal(pdf_vals, target_pdf_vals_unstandardized, tolerance = 1e-07) + expect_equal(pdf_vals, target_pdf_vals_unstandardized, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, @@ -597,7 +595,7 @@ test_that("probability density estimation works as expected", { 0.2352683 ) expect_equal(pdf_vals, target_pdf_vals_unstandardized_clipped, - tolerance = 1e-07) + tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, @@ -620,7 +618,7 @@ test_that("probability density estimation works as expected", { 0.1247126, 0.2253963 ) - expect_equal(pdf_vals, target_pdf_vals_standardized, tolerance = 1e-07) + expect_equal(pdf_vals, target_pdf_vals_standardized, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10) pdf_vals <- hermite_est %>% dens(x) @@ -673,14 +671,14 @@ test_that("cumulative distribution function estimation works as expected", upper = 0.5 )$value cdf_est <- hermite_est %>% cum_prob(0.5) - expect_equal(cdf_est, 0.6549575, tolerance = 1e-07) - expect_equal(cdf_from_pdf, cdf_est, tolerance = 1e-07) + expect_equal(cdf_est, 0.6549575, tolerance = get_eps()) + expect_equal(cdf_from_pdf, cdf_est, tolerance = get_eps()) cdf_est <- hermite_est %>% cum_prob(0.5, clipped=TRUE) - expect_equal(cdf_est, 0.6549575, tolerance = 1e-07) + expect_equal(cdf_est, 0.6549575, tolerance = get_eps()) cdf_est <- hermite_est %>% cum_prob(3, clipped=TRUE) - expect_equal(cdf_est, 1, tolerance = 1e-07) + expect_equal(cdf_est, 1, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, standardize = TRUE) %>% @@ -693,8 +691,8 @@ test_that("cumulative distribution function estimation works as expected", upper = 0.5 )$value cdf_est <- hermite_est %>% cum_prob(0.5) - expect_equal(cdf_est, 0.6013645, tolerance = 1e-07) - expect_equal(cdf_from_pdf, cdf_est, tolerance = 1e-07) + expect_equal(cdf_est, 0.6013645, tolerance = get_eps()) + expect_equal(cdf_from_pdf, cdf_est, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, @@ -712,8 +710,8 @@ test_that("cumulative distribution function estimation works as expected", upper = 0.5 )$value cdf_est <- hermite_est %>% cum_prob(0.5) - expect_equal(cdf_est, 0.6132811, tolerance = 1e-07) - expect_equal(cdf_from_pdf, cdf_est, tolerance = 1e-07) + expect_equal(cdf_est, 0.6132811, tolerance = get_eps()) + expect_equal(cdf_from_pdf, cdf_est, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, @@ -731,8 +729,8 @@ test_that("cumulative distribution function estimation works as expected", upper = 0.5 )$value cdf_est <- hermite_est %>% cum_prob(0.5) - expect_equal(cdf_est, 0.4344541, tolerance = 1e-07) - expect_equal(cdf_from_pdf, cdf_est, tolerance = 1e-07) + expect_equal(cdf_est, 0.4344541, tolerance = get_eps()) + expect_equal(cdf_from_pdf, cdf_est, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10) expect_equal(hermite_est %>% cum_prob(0.5),NA) @@ -777,7 +775,7 @@ test_that("quantile estimation works as expected", { quantiles_est <- hermite_est %>% quant(c(0.25, 0.5, 0.75)) expect_equal(quantiles_est, c(-1.31079556, 0.04139707, 0.90912314), - tolerance = 1e-07) + tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, standardize = TRUE) for (idx in seq_along(test_observations)) { hermite_est <- @@ -786,7 +784,7 @@ test_that("quantile estimation works as expected", { quantiles_est <- hermite_est %>% quant(c(0.25, 0.5, 0.75)) expect_equal(quantiles_est, c(-0.5984749, 0.1403919, 1.1469321), - tolerance = 1e-07) + tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, standardize = TRUE, @@ -797,13 +795,13 @@ test_that("quantile estimation works as expected", { } quantiles_est <- hermite_est %>% quant(c(0.25, 0.5, 0.75)) expect_equal(quantiles_est, c(-0.05505796, 0.36015454, 1.43755939), - tolerance = 1e-06) + tolerance = get_eps()) hermite_est <- hermite_estimator(N = 30, standardize = TRUE) %>% update_batch(c(1:4)) quantiles_est <- hermite_est %>% quant(c(0.5)) expect_equal(quantiles_est,2.5, - tolerance = 1e-02) + tolerance = get_eps()) }) test_that("convenience and utility functions work as expected", { @@ -812,14 +810,14 @@ test_that("convenience and utility functions work as expected", { c( 1 ) - expect_equal(hermite_poly_vals,target_values,tolerance=1e-6) + expect_equal(hermite_poly_vals,target_values,tolerance=get_eps()) hermite_poly_vals <- as.vector(hermite_polynomial_N(N=1,x=c(2))) target_values <- c( 1, 4 ) - expect_equal(hermite_poly_vals,target_values,tolerance=1e-6) + expect_equal(hermite_poly_vals,target_values,tolerance=get_eps()) hermite_poly_vals <- as.vector(hermite_polynomial_N(N=6,x=c(2))) target_values <- c( @@ -831,20 +829,20 @@ test_that("convenience and utility functions work as expected", { -16, -824 ) - expect_equal(hermite_poly_vals,target_values,tolerance=1e-6) + expect_equal(hermite_poly_vals,target_values,tolerance=get_eps()) hermite_function_vals <- as.vector(hermite_function_N(N=0,x=c(2))) target_values <- c( 0.101653788306418 ) - expect_equal(hermite_function_vals,target_values,tolerance=1e-6) + expect_equal(hermite_function_vals,target_values,tolerance=get_eps()) hermite_function_vals <- as.vector(hermite_function_N(N=1,x=c(2))) target_values <- c( 0.101653788306418, 0.287520332179079 ) - expect_equal(hermite_function_vals,target_values,tolerance=1e-6) + expect_equal(hermite_function_vals,target_values,tolerance=get_eps()) hermite_function_vals <- as.vector(hermite_function_N(N=6,x=c(2))) target_values <- c( @@ -856,41 +854,43 @@ test_that("convenience and utility functions work as expected", { -0.0262468952793101, -0.390206540413716 ) - expect_equal(hermite_function_vals,target_values,tolerance=1e-6) + expect_equal(hermite_function_vals,target_values,tolerance=get_eps()) target_integral <- stats::integrate(f=function(t) {hermite_function_N(N=6,t)[7,]}, lower=-Inf, upper=5)$value hermite_int_lower_val <- hermite_int_lower(N=6,x=5)[7] - expect_equal(target_integral,hermite_int_lower_val,tolerance=1e-4) + expect_equal(target_integral,hermite_int_lower_val,tolerance=get_eps()) target_integral <- stats::integrate(f=function(t){ hermite_function_N(N=6,t)[7,]}, lower=2, upper=Inf)$value hermite_int_upper_val <- hermite_int_upper(N=6,x=2)[7] - expect_equal(target_integral,hermite_int_upper_val,tolerance=1e-4) + expect_equal(target_integral,hermite_int_upper_val,tolerance=get_eps()) target_integral <- stats::integrate(f=function(t){ hermite_function_N(N=6,t)[7,]}, lower=-Inf, upper=Inf)$value hermite_int_full <- hermite_int_full(N=6)[7] - expect_equal(target_integral,hermite_int_full,tolerance=1e-4) + expect_equal(target_integral,hermite_int_full,tolerance=get_eps()) target_integral <- stats::integrate(function(x){x*exp(-x^2)}, lower=-Inf,upper=Inf)$value quad_val <- gauss_hermite_quad_100(function(x){x}) - expect_equal(target_integral,quad_val,tolerance=1e-5) + expect_equal(target_integral,quad_val,tolerance=get_eps()) hermite_function_sum_vals <- as.vector( rowSums(hermite_function_N(N=6,x=c(1)))) expect_equal(hermite_function_sum_vals, - hermite_function_sum_N(N=6,x=c(1)),tol=1e-7) + hermite_function_sum_N(N=6,x=c(1)), + tolerance=get_eps()) hermite_function_sum_vals <- as.vector( rowSums(hermite_function_N(N=6,x=c(1,2)))) expect_equal(hermite_function_sum_vals, - hermite_function_sum_N(N=6,x=c(1,2)),tol=1e-7) + hermite_function_sum_N(N=6,x=c(1,2)),tolerance=get_eps()) hermite_function_sum_vals <- as.vector( rowSums(hermite_function_N(N=6,x=c(1,2,3)))) expect_equal(hermite_function_sum_vals, - hermite_function_sum_N(N=6,x=c(1,2,3)),tol=1e-7) + hermite_function_sum_N(N=6,x=c(1,2,3)),tolerance=get_eps()) hermite_function_sum_vals <- as.vector( rowSums(hermite_function_N(N=6,x=c(1,2,3,4)))) expect_equal(hermite_function_sum_vals, - hermite_function_sum_N(N=6,x=c(1,2,3,4)),tol=1e-7) + hermite_function_sum_N(N=6,x=c(1,2,3,4)),tolerance=get_eps()) hermite_function_sum_vals <- as.vector( rowSums(hermite_function_N(N=6,x=seq(-4,4,by=0.5)))) expect_equal(hermite_function_sum_vals, - hermite_function_sum_N(N=6,x=seq(-4,4,by=0.5)),tol=1e-7) + hermite_function_sum_N(N=6,x=seq(-4,4,by=0.5)), + tolerance=get_eps()) }) diff --git a/tests/testthat/test_hermite_estimator_bivar.R b/tests/testthat/test_hermite_estimator_bivar.R index 1f76aab..f05a883 100644 --- a/tests/testthat/test_hermite_estimator_bivar.R +++ b/tests/testthat/test_hermite_estimator_bivar.R @@ -2,6 +2,10 @@ context("hermite_estimator_bivar") library(hermiter) library(magrittr) +get_eps <- function(){ + return(1e-3) +} + test_that("hermite_estimator_bivar constructor returns correct class", { hermite_est <- hermite_estimator(N = 10, @@ -175,23 +179,24 @@ test_that("batch updates of hermite_estimator_bivar work as expected", { hermite_est <- hermite_est %>% update_batch(test_observations_mat) expect_equal(target_coeff_vec_standardized_x, hermite_est$coeff_vec_x, - tolerance = 1e-07) + tolerance = get_eps()) expect_equal(target_coeff_vec_standardized_y, hermite_est$coeff_vec_y, - tolerance = 1e-07) - expect_equal(0.3512403, sum(hermite_est$coeff_mat_bivar), tolerance = 1e-06) + tolerance = get_eps()) + expect_equal(0.3512403, sum(hermite_est$coeff_mat_bivar), tolerance = + get_eps()) expect_equal(mean(test_observations_mat[, 1]), hermite_est$running_mean_x, - tolerance = 1e-06) + tolerance = get_eps()) expect_equal(mean(test_observations_mat[, 2]), hermite_est$running_mean_y, - tolerance = 1e-06) + tolerance = get_eps()) expect_equal(sd(test_observations_mat[, 1]), sqrt(hermite_est$running_variance_x / (hermite_est$num_obs - 1)), - tolerance = 1e-06) + tolerance = get_eps()) expect_equal(sd(test_observations_mat[, 2]), sqrt(hermite_est$running_variance_y / (hermite_est$num_obs - 1)), - tolerance = 1e-06) + tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, standardize = FALSE, @@ -199,17 +204,19 @@ test_that("batch updates of hermite_estimator_bivar work as expected", { hermite_est <- hermite_est %>% update_batch(test_observations_mat) expect_equal(target_coeff_vec_unstandardized_x, hermite_est$coeff_vec_x, - tolerance = 1e-07) + tolerance = get_eps()) expect_equal(target_coeff_vec_unstandardized_y, hermite_est$coeff_vec_y, - tolerance = 1e-07) - expect_equal(0.3421721, sum(hermite_est$coeff_mat_bivar), tolerance = 1e-06) + tolerance = get_eps()) + expect_equal(0.3421721, sum(hermite_est$coeff_mat_bivar), tolerance = + get_eps()) hermite_est <- hermite_estimator(N = 10, standardize = FALSE, est_type = "bivariate") hermite_est <- hermite_est %>% update_batch(c(0.1,0.4)) - expect_equal(0.3864793, sum(hermite_est$coeff_mat_bivar), tolerance = 1e-06) + expect_equal(0.3864793, sum(hermite_est$coeff_mat_bivar), tolerance = + get_eps()) }) test_that("sequential updates of hermite_estimator_bivar work as expected", @@ -349,10 +356,10 @@ test_that("sequential updates of hermite_estimator_bivar work as expected", } expect_equal(target_coeff_vec_standardized_x, hermite_est$coeff_vec_x, - tolerance = 1e-07) + tolerance = get_eps()) expect_equal(target_coeff_vec_standardized_y, hermite_est$coeff_vec_y, - tolerance = 1e-07) + tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, standardize = FALSE, @@ -363,10 +370,10 @@ test_that("sequential updates of hermite_estimator_bivar work as expected", } expect_equal(target_coeff_vec_unstandardized_x, hermite_est$coeff_vec_x, - tolerance = 1e-07) + tolerance = get_eps()) expect_equal(target_coeff_vec_unstandardized_y, hermite_est$coeff_vec_y, - tolerance = 1e-07) + tolerance = get_eps()) }) test_that( @@ -511,10 +518,10 @@ test_that( } expect_equal(target_coeff_vec_standardized_x, hermite_est$coeff_vec_x, - tolerance = 1e-07) + tolerance = get_eps()) expect_equal(target_coeff_vec_standardized_y, hermite_est$coeff_vec_y, - tolerance = 1e-07) + tolerance = get_eps()) hermite_est <- hermite_estimator( N = 10, @@ -528,10 +535,10 @@ test_that( } expect_equal(target_coeff_vec_unstandardized_x, hermite_est$coeff_vec_x, - tolerance = 1e-07) + tolerance = get_eps()) expect_equal(target_coeff_vec_unstandardized_y, hermite_est$coeff_vec_y, - tolerance = 1e-07) + tolerance = get_eps()) } ) @@ -625,16 +632,16 @@ test_that("bivariate hermite estimators merge consistently", { update_batch(test_observations_mat[21:30, ]) hermite_merged <- merge_hermite_bivar(list(hermite_est_1)) - expect_equal(hermite_est_1, hermite_merged, tolerance = 1e-07) + expect_equal(hermite_est_1, hermite_merged, tolerance = get_eps()) hermite_merged <- merge_hermite(list(hermite_est_1)) - expect_equal(hermite_est_1, hermite_merged, tolerance = 1e-07) + expect_equal(hermite_est_1, hermite_merged, tolerance = get_eps()) hermite_merged <- merge_hermite_bivar(list(hermite_est_1, hermite_est_2, hermite_est_3)) - expect_equal(hermite_est, hermite_merged, tolerance = 1e-07) + expect_equal(hermite_est, hermite_merged, tolerance = get_eps()) hermite_merged <- merge_hermite(list(hermite_est_1, hermite_est_2, hermite_est_3)) - expect_equal(hermite_est, hermite_merged, tolerance = 1e-07) + expect_equal(hermite_est, hermite_merged, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, standardize = TRUE, @@ -658,7 +665,7 @@ test_that("bivariate hermite estimators merge consistently", { hermite_merged <- merge_pair(hermite_est_1, hermite_est_2) expect_equal(0.3236014, sum(hermite_merged$coeff_mat_bivar), tolerance = - 1e-07) + get_eps()) hermite_merged <- merge_hermite_bivar(list(hermite_est_1, hermite_est_2, hermite_est_3)) hermite_merged_gen <- @@ -666,17 +673,17 @@ test_that("bivariate hermite estimators merge consistently", { expect_equal(hermite_merged,hermite_merged_gen) expect_equal(hermite_est$running_mean_x, hermite_merged$running_mean_x, - tolerance = 1e-06) + tolerance = get_eps()) expect_equal(hermite_est$running_variance_x, hermite_merged$running_variance_x, - tolerance = 1e-06) + tolerance = get_eps()) expect_equal(hermite_est$running_mean_y, hermite_merged$running_mean_y, - tolerance = 1e-06) + tolerance = get_eps()) expect_equal(hermite_est$running_variance_y, hermite_merged$running_variance_y, - tolerance = 1e-06) - expect_equal(hermite_merged$num_obs, 30, tolerance = 1e-06) + tolerance = get_eps()) + expect_equal(hermite_merged$num_obs, 30, tolerance = get_eps()) hermite_est_univar_1_x <- hermite_estimator(N = 10, standardize = T) %>% @@ -710,12 +717,12 @@ test_that("bivariate hermite estimators merge consistently", { )) expect_equal(hermite_merged$coeff_vec_x, hermite_merged_univar_x$coeff_vec, - tolerance = 1e-06) + tolerance = get_eps()) expect_equal(hermite_merged$coeff_vec_y, hermite_merged_univar_y$coeff_vec, - tolerance = 1e-06) + tolerance = get_eps()) expect_equal(sum(hermite_merged$coeff_mat_bivar), 0.3444092, - tolerance = 1e-04) + tolerance = get_eps()) hermite_est_1 <- hermite_estimator(N = 10, standardize = FALSE, est_type = "bivariate") %>% update_batch(test_observations_mat[1:10,]) @@ -824,7 +831,7 @@ test_that("bivariate probability density estimation works as expected", { 0.00219206360051186, -0.00045534467461236 ) - expect_equal(pdf_vals, target_pdf_vals_unstandardized, tolerance = 1e-07) + expect_equal(pdf_vals, target_pdf_vals_unstandardized, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, @@ -840,7 +847,7 @@ test_that("bivariate probability density estimation works as expected", { 0.0028586637344242, -0.000421779530883988 ) - expect_equal(pdf_vals, target_pdf_vals_standardized, tolerance = 1e-07) + expect_equal(pdf_vals, target_pdf_vals_standardized, tolerance = get_eps()) target_pdf_vals_standardized <- c(0.0143447460506261, @@ -849,7 +856,7 @@ test_that("bivariate probability density estimation works as expected", { 0.0028586637344242, 1e-08) pdf_vals <- hermite_est %>% dens(x_mat, clipped = T) - expect_equal(pdf_vals, target_pdf_vals_standardized, tolerance = 1e-07) + expect_equal(pdf_vals, target_pdf_vals_standardized, tolerance = get_eps()) hermite_est <- hermite_estimator( @@ -871,7 +878,7 @@ test_that("bivariate probability density estimation works as expected", { 0.00163105161328314, -0.00106262644848195 ) - expect_equal(pdf_vals, target_pdf_vals_unstandardized, tolerance = 1e-07) + expect_equal(pdf_vals, target_pdf_vals_unstandardized, tolerance = get_eps()) pdf_vals <- hermite_est %>% dens(x_mat, clipped = TRUE) target_pdf_vals_unstandardized_clipped <- @@ -882,7 +889,7 @@ test_that("bivariate probability density estimation works as expected", { 1e-08) expect_equal(pdf_vals, target_pdf_vals_unstandardized_clipped, - tolerance = 1e-07) + tolerance = get_eps()) hermite_est <- hermite_estimator( @@ -904,7 +911,7 @@ test_that("bivariate probability density estimation works as expected", { -0.000447725087235188, 0.000498681697647531 ) - expect_equal(pdf_vals, target_pdf_vals_standardized, tolerance = 1e-07) + expect_equal(pdf_vals, target_pdf_vals_standardized, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, est_type = "bivariate") pdf_vals <- hermite_est %>% dens(x_mat) @@ -1003,7 +1010,7 @@ test_that("bivariate cumulative probability estimation works as expected", inner_integral(y) }, lower = -Inf, upper = 1)$value est_cdf <- hermite_est %>% cum_prob(c(0.5, 1)) - expect_equal(est_cdf, target_cdf, tolerance = 1e-04) + expect_equal(est_cdf, target_cdf, tolerance = get_eps()) test_observations <- c( -0.37826482129403, @@ -1089,7 +1096,7 @@ test_that("bivariate cumulative probability estimation works as expected", inner_integral(y) }, lower = -Inf, upper = 1)$value est_cdf <- hermite_est %>% cum_prob(c(0.5, 1)) - expect_equal(est_cdf, target_cdf, tolerance = 1e-04) + expect_equal(est_cdf, target_cdf, tolerance = get_eps()) hermite_est <- hermite_estimator( @@ -1114,7 +1121,7 @@ test_that("bivariate cumulative probability estimation works as expected", inner_integral(y) }, lower = -Inf, upper = 1)$value est_cdf <- hermite_est %>% cum_prob(c(0.5, 1)) - expect_equal(est_cdf, target_cdf, tolerance = 1e-04) + expect_equal(est_cdf, target_cdf, tolerance = get_eps()) hermite_est <- hermite_estimator( @@ -1139,7 +1146,7 @@ test_that("bivariate cumulative probability estimation works as expected", inner_integral(y) }, lower = -Inf, upper = 1)$value est_cdf <- hermite_est %>% cum_prob(c(0.5, 1)) - expect_equal(est_cdf, target_cdf, tolerance = 1e-04) + expect_equal(est_cdf, target_cdf, tolerance = get_eps()) x_vals <- c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5) x_mat <- matrix(x_vals, @@ -1161,7 +1168,7 @@ test_that("bivariate cumulative probability estimation works as expected", 1.02900881440701 ) expect_equal(cdf_vals, target_cdf_vals_unstandardized, - tolerance = 1e-07) + tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, standardize = TRUE, @@ -1177,7 +1184,7 @@ test_that("bivariate cumulative probability estimation works as expected", 1.02819373498816 ) expect_equal(cdf_vals, target_cdf_vals_standardized, - tolerance = 1e-07) + tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, standardize = TRUE, @@ -1187,7 +1194,7 @@ test_that("bivariate cumulative probability estimation works as expected", target_cdf_vals_standardized <- c(0.87449356687884, 0.871314320667304, 1, 1, 1) expect_equal(cdf_vals, target_cdf_vals_standardized, - tolerance = 1e-07) + tolerance = get_eps()) hermite_est <- hermite_estimator( N = 10, @@ -1209,7 +1216,7 @@ test_that("bivariate cumulative probability estimation works as expected", 0.986646514574038 ) expect_equal(cdf_vals, target_cdf_vals_unstandardized, - tolerance = 1e-07) + tolerance = get_eps()) hermite_est <- hermite_estimator( N = 10, @@ -1231,7 +1238,7 @@ test_that("bivariate cumulative probability estimation works as expected", 0.963606285800644 ) expect_equal(cdf_vals, target_cdf_vals_standardized, - tolerance = 1e-07) + tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, est_type = "bivariate") cdf_vals <- hermite_est %>% cum_prob(x_mat) @@ -1356,7 +1363,7 @@ test_that("bivariate Spearman's correlation estimation works as expected", inner_integral(y) }, lower = -Inf, upper = Inf)$value est_spear <- hermite_est %>% spearmans() - expect_equal(target_spear, est_spear, tolerance = 1e-04) + expect_equal(target_spear, est_spear, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, @@ -1376,7 +1383,7 @@ test_that("bivariate Spearman's correlation estimation works as expected", inner_integral(y) }, lower = -Inf, upper = Inf)$value est_spear <- hermite_est %>% spearmans() - expect_equal(target_spear, est_spear, tolerance = 1e-04) + expect_equal(target_spear, est_spear, tolerance = get_eps()) hermite_est <- hermite_estimator( @@ -1402,7 +1409,7 @@ test_that("bivariate Spearman's correlation estimation works as expected", inner_integral(y) }, lower = -Inf, upper = Inf)$value est_spear <- hermite_est %>% spearmans() - expect_equal(target_spear, est_spear, tolerance = 1e-04) + expect_equal(target_spear, est_spear, tolerance = get_eps()) hermite_est <- hermite_estimator( @@ -1428,7 +1435,7 @@ test_that("bivariate Spearman's correlation estimation works as expected", inner_integral(y) }, lower = -Inf, upper = Inf)$value est_spear <- hermite_est %>% spearmans() - expect_equal(target_spear, est_spear, tolerance = 1e-04) + expect_equal(target_spear, est_spear, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, @@ -1436,7 +1443,7 @@ test_that("bivariate Spearman's correlation estimation works as expected", est_type = "bivariate") %>% update_batch(test_observations_mat) spear_est <- hermite_est %>% spearmans() - expect_equal(spear_est, 0.5486199, tolerance = 1e-06) + expect_equal(spear_est, 0.5486199, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, @@ -1444,7 +1451,7 @@ test_that("bivariate Spearman's correlation estimation works as expected", est_type = "bivariate") %>% update_batch(test_observations_mat) spear_est <- hermite_est %>% spearmans() - expect_equal(spear_est, 0.5639886, tolerance = 1e-06) + expect_equal(spear_est, 0.5639886, tolerance = get_eps()) hermite_est <- hermite_estimator( @@ -1458,7 +1465,7 @@ test_that("bivariate Spearman's correlation estimation works as expected", hermite_est %>% update_sequential(test_observations_mat[idx, ]) } spear_est <- hermite_est %>% spearmans() - expect_equal(spear_est, 0.4455951, tolerance = 1e-06) + expect_equal(spear_est, 0.4455951, tolerance = get_eps()) hermite_est <- hermite_estimator( @@ -1472,7 +1479,7 @@ test_that("bivariate Spearman's correlation estimation works as expected", hermite_est %>% update_sequential(test_observations_mat[idx, ]) } spear_est <- hermite_est %>% spearmans() - expect_equal(spear_est, 0.4494662, tolerance = 1e-06) + expect_equal(spear_est, 0.4494662, tolerance = get_eps()) hermite_est <- hermite_estimator( @@ -1486,7 +1493,7 @@ test_that("bivariate Spearman's correlation estimation works as expected", hermite_est %>% update_sequential(test_observations_mat[idx, ]) } spear_est <- hermite_est %>% spearmans(clipped = TRUE) - expect_equal(spear_est, 0.4494662, tolerance = 1e-06) + expect_equal(spear_est, 0.4494662, tolerance = get_eps()) hermite_est <- hermite_estimator(N = 10, est_type = "bivariate")