Skip to content

Commit 1a9afd3

Browse files
authored
Merge pull request #381 from stan-dev/fix-gpdfit
Restore original loo k behaviour
2 parents 720bb30 + 8671675 commit 1a9afd3

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

R/psis.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ psis_smooth_tail <- function(x, cutoff) {
257257
fit <- posterior::gpdfit(exp(x) - exp_cutoff, sort_x = FALSE)
258258
k <- fit$k
259259
sigma <- fit$sigma
260+
if (is.na(k)) {
261+
k <- Inf
262+
}
260263
if (is.finite(k)) {
261264
p <- (seq_len(len) - 0.5) / len
262265
qq <- posterior::qgeneralized_pareto(p, 0, sigma, k) + exp_cutoff

tests/testthat/test_psis.R

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,9 @@ test_that("do_psis_i throws warning if all tail values the same", {
153153
})
154154

155155
test_that("psis_smooth_tail returns original tail values if k is infinite", {
156-
# skip on M1 Mac until we figure out why this test fails only on M1 Mac
157-
skip_if(Sys.info()[["sysname"]] == "Darwin" && R.version$arch == "aarch64")
158-
159-
xx <- c(1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4)
160-
val <- suppressWarnings(psis_smooth_tail(xx, 3))
156+
xx <- log(c(2, 2, 2, 2, 3, 4, 5, 6))
157+
val <- suppressWarnings(psis_smooth_tail(xx, 0))
161158
expect_equal(val$tail, xx)
162159
expect_equal(val$k, Inf)
163160
})
161+

0 commit comments

Comments
 (0)