-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Don't drop weights when subsetting variables? #298
Comments
I forgot to mention that other hidden reserved variables (other than |
I think, we need to make an explicit design decision on whether we want to retain hidden variables or not when subsetting via That said, you can always use |
Hmmm, that's a tough one. It does seem like the default behavior of |
I agree. So both [] and subset(_draws) should keep reserved variables by default but both gain an argument to turn this off? Sounds like a good approach to me. |
Sounds good to me too. |
One challenge towards this will be that we cannot just use `[.draws_matrix` <- function(x, i, j, ..., drop = FALSE) {
# TODO: allow for argument 'reserved' as in '[.draws_df'
# right now this fails because NextMethod() cannot ignore arguments
out <- NextMethod("[", drop = drop)
if (length(dim(out)) == length(dim(x))) {
class(out) <- class(x)
.nchains <- nchains(x)
if (missing(i)) {
attr(out, "nchains") <- .nchains
} else if (.nchains > 1L) {
warn_merge_chains("index")
}
}
out
} Just leaving this here for furture reference because I will surely forget otherwise. |
I noticed that subsetting the variables of a
draws
object will drop weights:Created on 2023-08-15 with reprex v2.0.2
As you can see,
x_sub
lacks the hidden reserved variable.log_weight
.I'm not sure if this is intended behavior or not, but I think subsetting variables (variables only, not the draws or chains) should keep weights.
The text was updated successfully, but these errors were encountered: