-
Notifications
You must be signed in to change notification settings - Fork 2
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
pmap
variants not handling .l
properly
#11
Labels
bug
Something isn't working
Comments
More tests: library(purrr)
library(collateral)
list1 = 1:5
list2 = c('red', 'blue', 'yellow', 'green', 'purple')
list3 = 6:10
all_lists = list(list1, list2, list3)
# classic pmap or pmap_chr works regardless of how function is specified
pmap(all_lists, function(list1, list2, list3) { paste(list1, list2, list3) })
#> [[1]]
#> [1] "1 red 6"
#>
#> [[2]]
#> [1] "2 blue 7"
#>
#> [[3]]
#> [1] "3 yellow 8"
#>
#> [[4]]
#> [1] "4 green 9"
#>
#> [[5]]
#> [1] "5 purple 10"
pmap(all_lists, ~ paste(..1, ..2, ..3))
#> [[1]]
#> [1] "1 red 6"
#>
#> [[2]]
#> [1] "2 blue 7"
#>
#> [[3]]
#> [1] "3 yellow 8"
#>
#> [[4]]
#> [1] "4 green 9"
#>
#> [[5]]
#> [1] "5 purple 10"
pmap_chr(all_lists, ~ paste(..1, ..2, ..3))
#> [1] "1 red 6" "2 blue 7" "3 yellow 8" "4 green 9" "5 purple 10"
# collateral variants do not, although they handle the errors themselves
# in this case
safe_test <- pmap_safely(all_lists, ~ paste(..1, ..2, ..3))
quiet_test <- pmap_quietly(all_lists, ~ paste(..1, ..2, ..3))
#> Error in paste(..1, ..2, ..3): the ... list contains fewer than 2 elements
peaceful_test <- pmap_peacefully(all_lists, ~ paste(..1, ..2, ..3))
safe_test
#> _ E
#> _ E
#> _ E
str(safe_test)
#> List of 3
#> $ :List of 2
#> ..$ result: NULL
#> ..$ error :List of 2
#> .. ..$ message: chr "the ... list contains fewer than 2 elements"
#> .. ..$ call : language paste(..1, ..2, ..3)
#> .. ..- attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
#> $ :List of 2
#> ..$ result: NULL
#> ..$ error :List of 2
#> .. ..$ message: chr "the ... list contains fewer than 2 elements"
#> .. ..$ call : language paste(..1, ..2, ..3)
#> .. ..- attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
#> $ :List of 2
#> ..$ result: NULL
#> ..$ error :List of 2
#> .. ..$ message: chr "the ... list contains fewer than 2 elements"
#> .. ..$ call : language paste(..1, ..2, ..3)
#> .. ..- attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
#> - attr(*, "class")= chr [1:2] "safely_mapped" "list"
quiet_test
#> Error in eval(expr, envir, enclos): object 'quiet_test' not found
str(quiet_test)
#> Error in str(quiet_test): object 'quiet_test' not found
peaceful_test
#> _ O _ _ E
#> _ O _ _ E
#> _ O _ _ E
str(peaceful_test)
#> List of 3
#> $ :List of 5
#> ..$ result : NULL
#> ..$ output : chr ""
#> ..$ warnings: chr(0)
#> ..$ messages: chr(0)
#> ..$ error :List of 2
#> .. ..$ message: chr "the ... list contains fewer than 2 elements"
#> .. ..$ call : language paste(..1, ..2, ..3)
#> .. ..- attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
#> $ :List of 5
#> ..$ result : NULL
#> ..$ output : chr ""
#> ..$ warnings: chr(0)
#> ..$ messages: chr(0)
#> ..$ error :List of 2
#> .. ..$ message: chr "the ... list contains fewer than 2 elements"
#> .. ..$ call : language paste(..1, ..2, ..3)
#> .. ..- attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
#> $ :List of 5
#> ..$ result : NULL
#> ..$ output : chr ""
#> ..$ warnings: chr(0)
#> ..$ messages: chr(0)
#> ..$ error :List of 2
#> .. ..$ message: chr "the ... list contains fewer than 2 elements"
#> .. ..$ call : language paste(..1, ..2, ..3)
#> .. ..- attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
#> - attr(*, "class")= chr [1:2] "peacefully_mapped" "list" Created on 2019-07-08 by the reprex package (v0.3.0) |
Think I've caught it: the |
jimjam-slam
added a commit
that referenced
this issue
Jul 8, 2019
Fixed in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems like the
map
variants are mishandling.l
somehow. The following error suggests thatpurrr::pmap()
is trying to iterate over.l
, rather than iterate down the elements of.l
in parallel:Created on 2019-07-08 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: