-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attempt to use namespaces for stan_lmer
and survreg
#363
Conversation
I think you will also need to use GitHub version of datawizard for this to work. |
Co-authored-by: Indrajeet Patil <[email protected]>
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #363 +/- ##
==========================================
+ Coverage 60.92% 67.32% +6.40%
==========================================
Files 46 46
Lines 3173 3244 +71
==========================================
+ Hits 1933 2184 +251
+ Misses 1240 1060 -180
... and 12 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
This test works locally: x1 <- lm(Sepal.Length ~ Petal.Length * Species, data = iris)
testthat::expect_identical(
as.character(report::report_performance(x1)),
paste(
"The model explains a statistically significant and substantial proportion of",
"variance (R2 = 0.84, F(5, 144) = 151.71, p < .001, adj. R2 = 0.83)"
)
) Created on 2023-04-13 with reprex v2.0.2 But not using the random order test script in the console: > purrr::walk(randomized_test_script_paths, test_path)
✔ All tests passing in `tests/testthat/test-report.data.frame.R`.
✔ All tests passing in `tests/testthat/test-report.lm.R`.
✔ All tests passing in `tests/testthat/test-format_model.R`.
✖ There was error while running tests in `tests/testthat/test-report_performance.R`.
Test `report_performance` has error:
expectation_success: as.character(report_performance(x1)) (`actual`) not identical to paste(...) (`expected`). Even after renaming from x to x1 (there is no other object called x1). The tests are also fully contained within a testthat call. So no idea what the issue is? |
I am not able to update snapshots for file
Same behaviour when using RStudio's "Run Tests" or "Test" buttons. @etiennebacher any idea? Namespace conflicts is your area of expertise now no? :P |
Actually we can see the |
It's hard to explain but I think when One solution is to use |
Interesting! I don't fully get it but it seems to work, thanks! :D |
@rempsyc Can you please also have a look at the test failure in random order? Also, test coverage workflow is failing. |
All tests are finally passing, yeah! :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work, Remi! Thanks 😊
@etiennebacher the Error in `eval(code, test_env)`: cannot change value of locked binding for 'stan_glmer' A brief online search seems to confirm that this error is generated when using super assignment. In fact, it seems that this error arises when suppressPackageStartupMessages(library(rstanarm))
stan_glmer <<- rstanarm::stan_glmer
#> Error in eval(expr, envir, enclos): cannot change value of locked binding for 'stan_glmer' Created on 2023-05-07 with reprex v2.0.2 Although we don't load it explicitly, sometimes, but not all the time (because this is rstanarm.....), it will load by itself just through using namespace. Any idea for the best way to fix this? I also opened an issue at stan-dev/rstanarm#589 |
[I posted this by mistake in the This is very well explained in this SO answer. Paraphrasing what is said there, the problem is that there's already a I think one solution would be to check whether is_stan_glmer_avail <- !inherits(try(stan_glmer, silent = TRUE), "try-error")
if (!is_stan_glmer_avail) {
stan_glmer <<- rstanarm::stan_glmer
on.exit(remove(stan_glmer, envir = .GlobalEnv))
} (don't forget to remove the Can you check if this works? It works for me locally but I couldn't reproduce the error when running |
Thanks @etiennebacher that seems to have solved the issue!! :) |
Attempt to use namespaces for
stan_lmer
andsurvreg
. As showed in easystats/datawizard#401, works in reprex locally and console, but not in tests, so testing here to see if it fixes itself.