Skip to content

Commit 87024b1

Browse files
authored
Merge pull request #398 from thanasibakis/master
Fix permutations argument in `crps.numeric` and `scrps.numeric`
2 parents 39918e5 + 9570270 commit 87024b1

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎NEWS.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ and moment matching in #395
66
comparison-model minus reference-model by @florence-bockting in #391
77
* Update user messages in `print()` by @ishaan-arora-1, @florence-bockting in
88
#328.
9+
* Fix `crps()` and `scrps()` ignoring the `permutations` argument for numeric
10+
input by @thanasibakis in #398
911

1012
# loo 2.10.1
1113

‎R/crps.R‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ crps.matrix <- function(x, x2, y, ..., permutations = 1) {
9494
crps.numeric <- function(x, x2, y, ..., permutations = 1) {
9595
stopifnot(length(x) == length(x2),
9696
length(y) == 1)
97-
crps.matrix(as.matrix(x), as.matrix(x2), y, permutations)
97+
crps.matrix(as.matrix(x), as.matrix(x2), y, permutations = permutations)
9898
}
9999

100100

@@ -140,7 +140,7 @@ scrps.matrix <- function(x, x2, y, ..., permutations = 1) {
140140
scrps.numeric <- function(x, x2, y, ..., permutations = 1) {
141141
stopifnot(length(x) == length(x2),
142142
length(y) == 1)
143-
scrps.matrix(as.matrix(x), as.matrix(x2), y, permutations)
143+
scrps.matrix(as.matrix(x), as.matrix(x2), y, permutations = permutations)
144144
}
145145

146146

‎tests/testthat/test_crps.R‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,12 @@ test_that("methods for single data point don't error", {
5656
expect_silent(crps(x1[,1], x2[,1], y[1]))
5757
expect_silent(scrps(x1[,1], x2[,1], y[1]))
5858
})
59+
60+
test_that("methods for single data point pass permutations to matrix methods", {
61+
set.seed(1); a <- crps(x1[,1], x2[,1], y[1], permutations = 5)
62+
set.seed(1); b <- crps(x1[,1, drop = FALSE], x2[,1, drop = FALSE], y[1], permutations = 5)
63+
expect_equal(a, b)
64+
set.seed(1); a <- scrps(x1[,1], x2[,1], y[1], permutations = 5)
65+
set.seed(1); b <- scrps(x1[,1, drop = FALSE], x2[,1, drop = FALSE], y[1], permutations = 5)
66+
expect_equal(a, b)
67+
})

0 commit comments

Comments
 (0)