futureverse / future.apply

:rocket: R package: future.apply - Apply Function to Elements in Parallel using Futures
https://future.apply.futureverse.org
211 stars 16 forks source link

future_lapply(X) on lists X where X != as.list(X) #24

Closed HenrikBengtsson closed 6 years ago

HenrikBengtsson commented 6 years ago

For list objects X where X != as.list(X), future_lapply(X) did not give the same result as lapply(X). Example:

X <- structure(list(a = 1, b = 2), class = "Foo")
as.list.Foo <- function(x, ...) c(X, c = 3)

y0 <- lapply(X, FUN = length)
str(y0)
# List of 3
#  $ a: int 1
#  $ b: int 1
#  $ c: int 1

library(future.apply)
y1 <- future_lapply(X, FUN = length)
str(y1)
# List of 2
#  $ a: int 1
#  $ b: int 1
HenrikBengtsson commented 6 years ago

Same is true for future_vapply().

HenrikBengtsson commented 6 years ago

Fixed for the next release.