stan-dev / projpred

Projection predictive variable selection
https://mc-stan.org/projpred/
Other
110 stars 26 forks source link

Test Suite Crashes #425

Closed l-gorman closed 1 year ago

l-gorman commented 1 year ago

I have tried to run the projpred test suite when making changes. Here are the steps I took to set up:

  1. Fork projpred repository
  2. Download external dependencies which were needed (e.g. gfortran)
  3. Install dependencies with devtools::install_deps()
  4. Install development dependencies with devtools::install_dev_deps()
  5. Package built successfully with devtools::build()

However when I run devtools::test(), I get the following error in Rstudio:

image

When I try to do the same thing outside of Rstudio, just in a console, I get a segmenation fault:

R version 4.2.0 (2022-04-22) -- "Vigorous Calisthenics"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> devtools::load_all()
ℹ Loading projpred
This is projpred version 2.6.0.9000.
> devtools::test()
ℹ Testing projpred
This is projpred version 2.6.0.9000.
Selection:
Selection: 1 # I just tried 1 to see!
[1]    99236 segmentation fault  R

Have I missed anything in the setup, or is there a "developers guide" that I missing?

Sorry again for yet another question!

fweber144 commented 1 year ago

Thank you for creating this issue!

My first impression is that this is probably due to the (rstanarm) reference model fits which take place at the beginning of the tests (setup.R). In that case, it would not be related to projpred. Since I can't reproduce, would you mind running devtools::load_all(".") in a fresh R session (RStudio should be fine) and then going through setup.R step-by-step to see where the error occurs?

l-gorman commented 1 year ago

No problem! So I have run through setup.R, and there doesn't seem to be any issues!

fweber144 commented 1 year ago

Ok, then you could try to run

devtools::load_all(".")
source("tests/testthat/setup.R")
file_nms <- grep("^tests/testthat/test_.*\\.R$",
                 list.files(testthat::test_path(), full.names = TRUE),
                 value = TRUE)
for (file_nm in file_nms) {
  cat(file_nm, "\n")
  source(file_nm)
}

Do you get the same error/crash there?

l-gorman commented 1 year ago

So, no crashing when I run this! A lot of tests skipped, then these tests fail:

── Failure (tests/testthat/test_methods_vsel.R:615:3): ranking proportions are computed correctly ──
all(rowSums(pr_cF) == 1) is not TRUE

`actual`:   FALSE
`expected`: TRUE 
cumulate = FALSE

── Failure (tests/testthat/test_methods_vsel.R:616:3): ranking proportions are computed correctly ──
all(colSums(pr_cF) == 1) is not TRUE

`actual`:   FALSE
`expected`: TRUE 
cumulate = FALSE

── Failure (tests/testthat/test_methods_vsel.R:627:3): ranking proportions are computed correctly ──
`has_1_colwise` is not TRUE

`actual`:   FALSE
`expected`: TRUE 
cumulate = TRUE

 Error in reporter$stop_if_needed() : Test failed

This is the Traceback:


11.
stop(error)
10.
(function (envir) 
{
handlers <- get_handlers(envir)
errors <- list() ... at test_methods_vsel.R#609
9.
test_that("ranking proportions are computed correctly", {
skip_on_cran()
cv_proportions_tester(pr_cF, nterms_max_expected = ntrms, 
cnms_expected = rk_fdata, info_str = "cumulate = FALSE") ... at test_methods_vsel.R#609
8.
eval(ei, envir)
7.
eval(ei, envir)
6.
withVisible(eval(ei, envir))
5.
source(file_nm) at .active-rstudio-document#8
4.
eval(ei, envir)
3.
eval(ei, envir)
2.
withVisible(eval(ei, envir))
1.
source("~/.active-rstudio-document")

Hope that helps!!!

fweber144 commented 1 year ago

Yes, that helps :) Thank you!