Skip to content
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

bplapply does not handle NULL values #267

Open
RonanDaly opened this issue Feb 11, 2025 · 2 comments
Open

bplapply does not handle NULL values #267

RonanDaly opened this issue Feb 11, 2025 · 2 comments

Comments

@RonanDaly
Copy link

It's not clear to me what the correct behaviour should be, but bplapply stops with
an error whenever it encounters a NULL in X

bplapply(list(NULL), function(x) {
     42
})
Error: BiocParallel errors
  0 remote errors, element index: 
  1 unevaluated and other errors
  first remote error:
In addition: Warning message:
In .bploop_impl(ITER = ITER, FUN = FUN, ARGS = ARGS, BPPARAM = BPPARAM,  :
  first invocation of 'ITER()' returned NULL
> sessionInfo()
R version 4.4.2 (2024-10-31)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.6.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

time zone: Europe/London
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] BiocParallel_1.39.0

loaded via a namespace (and not attached):
[1] compiler_4.4.2   parallel_4.4.2   codetools_0.2-20

I tried this on an earlier version, which works

> bplapply(list(NULL), function(x) {
+      42
+ })
[[1]]
[1] 42
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] BiocParallel_1.18.0

loaded via a namespace (and not attached):
[1] compiler_3.6.3 parallel_3.6.3
@Jiefei-Wang
Copy link
Collaborator

This is because BiocParallel uses an iterator internally to handle the list object, and the iterator uses NULL value to determine the end of the sequence. Here is a better example. Unlike the example from @RonanDaly , this time BiocParallel does not end gracefully. There is no error message at all.

> bplapply(list(1,2,NULL,4), function(x) {
+     x
+ })
Error: BiocParallel errors
  0 remote errors, element index:
  1 unevaluated and other errors
  first remote error:

I think we should wrap the user-given NULL value so it would not terminate the iterator. What do you think? @mtmorgan . I can make a pull request for it.

@mtmorgan
Copy link
Collaborator

PR sounds great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants