-
Notifications
You must be signed in to change notification settings - Fork 116
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
Warining "... may be used in an incorrect context: ‘.fun(piece, ...)’" in plyr using parallel #203
Comments
I might have found a way to avoid the warnings. Will submit a pull request once it's good. |
The issue is in llply_parallel_test <- function(.data, .fun = NULL, ...) {
pieces <- .data
n <- length(pieces)
result <- vector("list", n)
dots <- eval(substitute(alist(...)))
do.ply <- function(i) {
piece <- pieces[[i]]
res <- do.call(.fun, c(piece, dots))
res
}
i <- seq_len(n)
fe_call <- as.call(c(list(as.name("foreach"), i = i)))
fe <- eval(fe_call)
result <- fe %dopar% do.ply(i)
attributes(result)[c("split_type", "split_labels")] <- attributes(pieces)[c("split_type", "split_labels")]
names(result) <- names(pieces)
if (!is.null(dim(pieces))) {
dim(result) <- dim(pieces)
}
result
} This seems to work if each element of require(doParallel)
cluster <- makeCluster(2, type = "SOCK")
registerDoParallel(cluster)
named_data <- plyr:::splitter_a(expand.grid(mean=1:5, sd=1:5))
llply_parallel_test(named_data, .fun = rnorm, n=2) However, it fails if the elements of margin1_data <- plyr:::splitter_a(ozone, .margins = 1)
margin1_mean <- llply_parallel_test(margin1_data, .fun = mean, na.rm=TRUE)
all.equal(unlist(margin1_mean), apply(ozone, 1, mean))
all.equal(unlist(margin1_mean), ozone[,1,1]) Note sure where to go from here... |
@jepusto: Does my pull request work for you? |
@krlmlr Unfortunately not--I think it may fail in the first case mentioned above. Try mdply(expand.grid(mean=1:5, sd=1.5), .fun = rnorm, n = 2, .parallel = TRUE) |
I'm getting
with my pull request #210. Is anything wrong with that? |
Sorry, I had a typo in my original--it should read mdply(expand.grid(mean=1:5, sd=1:5), .fun = rnorm, n = 2, .parallel = FALSE)
mdply(expand.grid(mean=1:5, sd=1:5), .fun = rnorm, n = 2, .parallel = TRUE) I haven't been able to get your pull request to build (probably a problem on my end), otherwise I would test it myself. |
Still works the same for me. Have you tried |
Ah thanks. |
I think this is fixed in the main branch now |
The bug seem to be back in plyr version 1.8.3. @renkun-ken code and similar request yields the same two warnings. cl <- makeCluster(2) l1 <- as.list(1:1000) stopCluster(cl) |
It didn't work in plyr version 1.8.2 either. I tried both doSnow and doParallel both showed the same message as above. |
Still does not work in plyr 1.8.3 |
Still does not work in plyr 1.8.4 |
I don't have too much time to look more closely but I saw two distinct behavior
Works properly.
Return a warning. Hope it will help. |
l.263: removed ellipsis in estimation() function l.284: suppressWarnings() in parallel estimation (seems to be a known bug with other packages too: cf. hadley/plyr#203) <- may not be the most elegant solution. Do you two have other ideas? l. 362-4: simulation stats now outputs estimation method used in the simulations
This package is terrific! But when I call
**ply
functions with parallel computing, warnings of... may be used in an incorrect context: ‘.fun(piece, ...)’
always occur.Here's a simple reproducible code:
Each time when I set
.parallel=T
to use the local two-node cluster, the computing finishes but with 2 warnings:If I don't enable
.parallel=T
and use sequential computing, the warnings do not appear.The same thing happens to
ddply()
too. Here's another example:The two warnings occurs too.
I don't get very useful information online. What's the problem here?
The text was updated successfully, but these errors were encountered: