Fix returning draws/sampling diagnostics for warmup with no samples#293
Fix returning draws/sampling diagnostics for warmup with no samples#293
Conversation
| private$metadata_ <- data_csv$metadata | ||
|
|
||
| if (!is.null(data_csv$post_warmup_draws)) { | ||
| missing_variables <- !(posterior::variables(data_csv$post_warmup_draws) %in% posterior::variables(private$draws_)) |
There was a problem hiding this comment.
This fixes an issue that is related to the main issue this PR is fixing. It was a bug all along but only surfaced with this.
library(cmdstanr)
stan_program <- file.path(cmdstan_path(), "examples/bernoulli/bernoulli.stan")
model <- cmdstan_model(stan_program)
stan_data <- list(N = 10, y = c(0,1,0,0,0,0,0,0,0,1))
fit3 = model$sample(data = stan_data, parallel_chains = 4, save_warmup = 1, iter_warmup = 100, iter_sampling = 0, save_latent_dynamics = TRUE)
fit3$draws() #works fine
fit3$draws() #fails
fit3$sampler_diagnostics() #works fine
fit3$sampler_diagnostics() #fails| y1 <- fit_mcmc_1$sampler_diagnostics(inc_warmup = FALSE) | ||
| y2 <- fit_mcmc_1$sampler_diagnostics(inc_warmup = TRUE) | ||
| y3 <- fit_mcmc_3$sampler_diagnostics(inc_warmup = TRUE) | ||
| y4 <- fit_mcmc_3$sampler_diagnostics(inc_warmup = FALSE) |
There was a problem hiding this comment.
Calling sampler_diagnostics() on the same fit would without https://github.com/stan-dev/cmdstanr/pull/293/files#r478645723
|
Both this PR and #294 are ready for review. |
Codecov Report
@@ Coverage Diff @@
## master #293 +/- ##
==========================================
+ Coverage 90.12% 90.15% +0.02%
==========================================
Files 12 12
Lines 2421 2427 +6
==========================================
+ Hits 2182 2188 +6
Misses 239 239
Continue to review full report at Codecov.
|
jgabry
left a comment
There was a problem hiding this comment.
Looks good, thanks! Some checks are still running but assuming they pass we can merge.
Submission Checklist
Summary
Fixes #288
Copyright and Licensing
Please list the copyright holder for the work you are submitting
(this will be you or your assignee, such as a university or company):
Rok Češnovar, Univ. of Ljubljana
By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the following licenses: