-
Notifications
You must be signed in to change notification settings - Fork 26
Merge in updated redist #197
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
base: dev
Are you sure you want to change the base?
Conversation
…ttle more to be done
…be incorrectly) tracked
…pose splitting actions to R
…ons and added more stuff to splitting file
…d redist_optimal_gsmc
…ead of preemptively
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.
This is much closer. I've added more comments and some existing ones were not yet resolved. Thanks Philip.
std_err <- sd(run_means) / sqrt(max(chain) - 1) # be slightly conservative | ||
} | ||
}else{ | ||
cli::cli_abort("Can't do non-coda std errors for single MCMC chain!") |
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.
This should be {.pkg coda}
.
R/diagnostics.R
Outdated
# ignore if not a supported algorithm | ||
if(!algo %in% summary_supported_algs){ | ||
cli::cli_abort("{.fn summary} is not supported for the {toupper(algo)} algorithm.") | ||
return(invisible(1)) |
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.
This return line doesn't ever get reached because it is after an abort.
all_splitting_methods <- sapply(all_run_info, function(x) x$split_method) | ||
if(length(unique(all_splitting_methods)) != 1){ | ||
cli::cli_abort("{.fn summary} is not supported for plans sampled using different splitting methods") | ||
return(invisible(1)) |
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.
Same for this return.
all_forward_kernel_params[[i]]$cut_k_used <- NULL | ||
if(!identical(all_forward_kernel_params[[1]], all_forward_kernel_params[[i]])){ | ||
cli::cli_abort("{.fn summary} is not supported for plans sampled using different splitting parameters") | ||
return(invisible(1)) |
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.
And this one.
|
||
existing_col <- names(tidyselect::eval_select(rlang::enquo(existing_plan), x)) | ||
if (length(existing_col) == 0) | ||
if (length(existing_col) == 0){ |
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.
Are we just catching NULL or is this related to new features?
#' @param fn A function | ||
#' @rdname constraints | ||
#' @export | ||
add_constr_custom_plan <- function( |
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.
Wait what's the difference between these two custom constraints now?
silent = silent | ||
) | ||
|
||
sampled_inidices <- sample.int(n = n_smc_nsims, size = chains, replace = F) |
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.
FALSE
control = list(), | ||
adapt_k_thresh = .99) { | ||
|
||
cli::cli_abort("redist_mergesplit_parallel is deprecated. Please call redist_mergesplit now.") |
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.
This should just be forwarding to the new redist_mergesplit with the special .Deprecated
# plans has n_precinct columns and n_sims rows | ||
# map is a redist_map | ||
# algorithm is one of "smc" or "mcmc" | ||
# algorithm is one of "smc" or "mcmc" or "smc_ms |
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.
missing "
@@ -0,0 +1,29 @@ | |||
# C++ Redist Code Overview |
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.
Does this file need to be added to the .Rbuildignore?
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.
@philipwosull when you run the formatter you have to match our existing formatting! 4-space indents among other things. That created a lot of diff noise that makes it hard to tell what substantively changed.
what is the status of devtools::check()
at this point?
.Call(`_redist_calcPWDh`, x) | ||
} | ||
|
||
#' |
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.
do we need to export these from c++ to R if they're not used by any package R code?
if we are going to keep them exported (f,rom c++) but internal, then I'd like to change the names, because people can still see these functions with :::
and the names are super verbose
std_err <- summary(mcmc)$statistics["Time-series SE"] | ||
if (isTRUE(by_chain)) { | ||
std_err <- std_err * sqrt(max(chain)) | ||
if(use_coda){ |
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.
We are also back to bad code formatting. Please fix the formatting throughout.
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.
the new summary()
is incredibly long. Can we break this up into multiple functions? Not a blocker for internal use but I really worry about long-term maintainability
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.
This is still in this PR
#' # One run with multiple cores | ||
#' redist_smc(fl_map, 1000, ncores = 2) |
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.
this is meant to demonstrate ncores
not nproc
. Add another example if you really want that, though I don't think we do want taht
weight_type = weight_type, | ||
nproc = nproc, | ||
ncores = ncores, | ||
custom_size_split_list = list(), |
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.
|
||
Papers: | ||
|
||
- O'Sullivan, P., McCartan, C., & Imai, K. (Working Paper Forthcoming). Generalized Sequential Monte Carlo Sampling for Larger-scale Redistricting Problems. |
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.
(in preparation)
would be the normal way to refer to this
#> Starting Chain 1 | ||
#> SEQUENTIAL MONTE CARLO | ||
#> Sampling 500 99-unit maps with 4 districts and population between 760,827 and 762,350. | ||
#> Using Graph Sampling space to sample 500 99-unit maps with 4 districts and population between 760827 and 762350. |
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.
@philipwosull what did you find here? is it something to do with the format string?
if (!missing(truncate)) { | ||
cli::cli_abort("{.arg truncate} is deprecated. Do not use this argument.") | ||
} | ||
if (!missing(trunc_fn)) { | ||
cli::cli_abort("{.arg truncate} is deprecated. Do not use this argument.") | ||
} | ||
if (!missing(final_infl)) { | ||
cli::cli_abort("{.arg truncate} is deprecated. Do not use this argument.") | ||
} |
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.
If these are hard deprecations then we should just remove them from the argument list!
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.
@christopherkenny I am fine with breaking changes for these args
@philipwosull when you get a chance, merge in |
…re generated fresh for each function call
Adding new sampling spaces, splitting methods, and smc weights among other things