From 86716755a439341a05100ba6ee4f0f314e3699c8 Mon Sep 17 00:00:00 2001 From: VisruthSK Date: Thu, 9 Jul 2026 23:05:45 -0700 Subject: [PATCH] Restore original loo k behaviour --- R/psis.R | 3 +++ tests/testthat/test_psis.R | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/R/psis.R b/R/psis.R index 463d8caf..dd8b0176 100644 --- a/R/psis.R +++ b/R/psis.R @@ -257,6 +257,9 @@ psis_smooth_tail <- function(x, cutoff) { fit <- posterior::gpdfit(exp(x) - exp_cutoff, sort_x = FALSE) k <- fit$k sigma <- fit$sigma + if (is.na(k)) { + k <- Inf + } if (is.finite(k)) { p <- (seq_len(len) - 0.5) / len qq <- posterior::qgeneralized_pareto(p, 0, sigma, k) + exp_cutoff diff --git a/tests/testthat/test_psis.R b/tests/testthat/test_psis.R index d43b6ed0..93d7501a 100644 --- a/tests/testthat/test_psis.R +++ b/tests/testthat/test_psis.R @@ -153,11 +153,9 @@ test_that("do_psis_i throws warning if all tail values the same", { }) test_that("psis_smooth_tail returns original tail values if k is infinite", { - # skip on M1 Mac until we figure out why this test fails only on M1 Mac - skip_if(Sys.info()[["sysname"]] == "Darwin" && R.version$arch == "aarch64") - - xx <- c(1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4) - val <- suppressWarnings(psis_smooth_tail(xx, 3)) + xx <- log(c(2, 2, 2, 2, 3, 4, 5, 6)) + val <- suppressWarnings(psis_smooth_tail(xx, 0)) expect_equal(val$tail, xx) expect_equal(val$k, Inf) }) +