twolodzko / kernelboot

Smoothed bootstrap and functions for sampling from kernel densities
3 stars 1 forks source link

BUG: Error in kernelboot( ... : object '.Random.seed' not found #6

Closed HenrikBengtsson closed 4 years ago

HenrikBengtsson commented 5 years ago

Hi, your kernelboot::kernelboot() assumes that .Random.seed exists (see below) but that is not always guaranteed to be the case.

> kernelboot::kernelboot
function (data, statistic, R = 500L, bw = "default", kernel = c("multivariate", 
    "gaussian", "epanechnikov", "rectangular", "triangular", 
    "biweight", "cosine", "optcosine", "none"), weights = NULL, 
    adjust = 1, shrinked = TRUE, ignore = NULL, parallel = FALSE, 
    workers = availableCores()) 
{
    call <- match.call()
    kernel <- match.arg(kernel)
    seed <- .Random.seed   <======== HERE
    n <- NROW(data)
    m <- NCOL(data)
    vars <- NULL

I think the simplest solution is to use:

    seed <- get0(".Random.seed", envir = .GlobalEnv, ifnotfound = NULL)

The reason why you haven't run into problems with this yet is when loading future (<= 1.14.0) together with your package, a side-effect was that .Random.seed was (incorrectly) created. I've now cleaned this up, which means that with future (> 1.14.0) .Random.seed may not be set. When running reverse package dependency checks, R CMD check kernelboot_0.1.5.tar.gz now produces:

* checking tests ...
  Running ‘test_parallel.R’
 ERROR
Running the tests in 'tests/test_parallel.R' failed.
Last 13 lines of output:
  +   set.seed(0xBEEF)
  +   s1 <- kernelboot(mtcars, function(data) coef(lm(mpg ~ disp + hp + drat, data = data)),
  +                    R = 10, parallel = TRUE)
  + 
  +   set.seed(0xBEEF)
  +   s2 <- kernelboot(mtcars, function(data) coef(lm(mpg ~ disp + hp + drat, data = data)),
  +                    R = 10, parallel = TRUE)
  + 
  +   stopifnot( all.equal(s1, s2) )
  + 
  + }
  Error in kernelboot(mtcars, function(data) coef(lm(mpg ~ disp + hp + drat,  : 
    object '.Random.seed' not found
  Calls: stopifnot -> kernelboot
  Execution halted
twolodzko commented 4 years ago

Thanks for the report and suggesting the solution.

HenrikBengtsson commented 4 years ago

Thanks. I've verified that kernelboot (master branch) works with the upcoming future 1.15.0, which I'd like to submit to CRAN rather soon. Would you mind submitting your kernelboot 0.1.6 to CRAN as soon as you have time?

twolodzko commented 4 years ago

@HenrikBengtsson I submitted it a week ago but they still didn't upload it...

HenrikBengtsson commented 4 years ago

Your package is sitting in ftp://cran.r-project.org/incoming/waiting/, which means CRAN is waiting for a response from you. Could be a hickup while running your tests triggering a false NOTE, WARNING, or ERROR. Check you emails / spam folder - what was the latest email notification you've got from them on Oct 31/Nov 1?

HenrikBengtsson commented 4 years ago

Correction: CRAN is waiting for a response from you

twolodzko commented 4 years ago

@HenrikBengtsson I wrote them two times. Unfortunately there is some strange warning in their autochecks, that does not seem to be related to my package. There doesn't seem much that I can do about it. Again, thanks for noticing me about the bug.

HenrikBengtsson commented 4 years ago

I see; I guess they just have a big backlog. Hopefully, this hurdle is just a one-time hiccup and it'll be smoother next time. Thxs.

HenrikBengtsson commented 4 years ago

I see kernelboot 0.1.6 is on CRAN now. Thxs again