Skip to content

Commit

Permalink
Solving CRAN issue (#403)
Browse files Browse the repository at this point in the history
* fixing the issue

* styling
  • Loading branch information
osorensen authored Mar 14, 2024
1 parent bb5c05b commit 6f6b85d
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: BayesMallows
Type: Package
Title: Bayesian Preference Learning with the Mallows Rank Model
Version: 2.1.0
Version: 2.1.1
Authors@R: c(person("Oystein", "Sorensen",
email = "oystein.sorensen.1985@gmail.com",
role = c("aut", "cre"),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# BayesMallows 2.1.1

* Fixed gcc-UBSAN issue happening when compute_mallows_sequentially() is run
without user IDs specified.

# BayesMallows 2.1.0

* The SMC method update_mallows() now supports pairwise preferences, both new
Expand Down
7 changes: 7 additions & 0 deletions R/compute_mallows_sequentially.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ compute_mallows_sequentially <- function(
if (!is.list(data) | !all(vapply(data, inherits, logical(1), "BayesMallowsData"))) {
stop("data must be a list of BayesMallowsData objects.")
}
if (any(
vapply(data, function(x) {
is.null(x$user_ids) || length(x$user_ids) == 0
}, logical(1))
)) {
stop("User IDs must be set.")
}
pfun_values <- extract_pfun_values(model_options$metric, data[[1]]$n_items, pfun_estimate)
alpha_init <- sample(initial_values$alpha, smc_options$n_particles, replace = TRUE)
rho_init <- initial_values$rho[, sample(ncol(initial_values$rho), smc_options$n_particles, replace = TRUE)]
Expand Down
2 changes: 1 addition & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Resubmission Note

This is a resubmission, fixing a failing unit test on noLD and containing a large number of new features.
This is a resubmission, fixing the gcc-UBSAN error reported on CRAN.


## Test Environments
Expand Down
2 changes: 1 addition & 1 deletion inst/examples/compute_mallows_sequentially_example.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Observe one ranking at each of 12 timepoints
library(ggplot2)
data <- lapply(seq_len(nrow(potato_visual)), function(i) {
setup_rank_data(potato_visual[i, ])
setup_rank_data(potato_visual[i, ], user_ids = i)
})

initial_values <- sample_prior(
Expand Down
2 changes: 1 addition & 1 deletion man/compute_mallows_sequentially.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions tests/testthat/test-compute_mallows_sequentially.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,24 @@ test_that("compute_mallows_sequentially works with partial rankings", {
)
)
})

test_that("compute_mallows_sequentially validates input", {
set.seed(345)
data <- lapply(seq_len(nrow(potato_visual)), function(i) {
setup_rank_data(potato_visual[i, ])
})

initial_values <- sample_prior(
n = 200, n_items = 20,
priors = set_priors(gamma = 3, lambda = .1)
)

expect_error(
compute_mallows_sequentially(
data = data,
initial_values = initial_values,
smc_options = set_smc_options(n_particles = 200, mcmc_steps = 20)
),
"User IDs must be set."
)
})
2 changes: 1 addition & 1 deletion work-docs/docker.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# On M1 Mac:
docker run -v "$(pwd)":"/opt/$(basename $(pwd))" --platform linux/amd64 -it --cap-add=SYS_PTRACE rocker/r-devel-san /bin/bash
docker run -v "$(pwd)":"/opt/$(basename $(pwd))" --platform linux/amd64 -it --cap-add=SYS_PTRACE rocker/r-devel-san-oyss /bin/bash

# On Intel Mac:
docker run -v "$(pwd)":"/opt/$(basename $(pwd))" -it --cap-add=SYS_PTRACE rocker/r-devel-san /bin/bash
Expand Down

0 comments on commit 6f6b85d

Please sign in to comment.