Skip to content

Commit

Permalink
muffle "X should be in range (0, 1)" warning (#788)
Browse files Browse the repository at this point in the history
* muffle "X should be in range (0, 1)" warning

* remove duplicate withCallingHandlers()

* rev version

---------

Co-authored-by: ‘topepo’ <‘[email protected]’>
  • Loading branch information
EmilHvitfeldt and ‘topepo’ authored Dec 18, 2023
1 parent e6b3309 commit 5b3a971
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: tune
Title: Tidy Tuning Tools
Version: 1.1.2.9004
Version: 1.1.2.9005
Authors@R: c(
person("Max", "Kuhn", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2402-136X")),
Expand Down
10 changes: 9 additions & 1 deletion R/tune_bayes.R
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,21 @@ fit_gp <- function(dat, pset, metric, control, eval_time = NULL, ...) {
}

opts <- list(...)

withCallingHandlers({
if (any(names(opts) == "trace") && opts$trace) {
gp_fit <- GPfit::GP_fit(X = x, Y = dat$mean, ...)
} else {
tmp_output <- utils::capture.output(
gp_fit <- GPfit::GP_fit(X = x, Y = dat$mean, ...)
)
}
}},
warning = function(w) {
if (w$message == "X should be in range (0, 1)") {
rlang::cnd_muffle(w)
}
}
)

gp_fit
}
Expand Down
12 changes: 0 additions & 12 deletions tests/testthat/_snaps/bayes.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,6 @@
Message
! The Gaussian process model is being fit using 1 features but only has 2
data points to do so. This may cause errors or a poor model fit.
! Gaussian process model: X should be in range (0, 1)
! Gaussian process model: X should be in range (0, 1)

# too few starting values

Expand Down Expand Up @@ -523,42 +521,32 @@
the Gaussian process model.
! The Gaussian process model is being fit using 1 features but only has 2
data points to do so. This may cause errors or a poor model fit.
! Gaussian process model: X should be in range (0, 1)
! For the rsq estimates, 1 missing value was found and removed before fitting
the Gaussian process model.
! Gaussian process model: X should be in range (0, 1)
! validation: internal: A correlation computation is required, but `estimate` is constant and ha...
! For the rsq estimates, 2 missing values were found and removed before
fitting the Gaussian process model.
! Gaussian process model: X should be in range (0, 1)
! validation: internal: A correlation computation is required, but `estimate` is constant and ha...
! For the rsq estimates, 3 missing values were found and removed before
fitting the Gaussian process model.
! Gaussian process model: X should be in range (0, 1)
! validation: internal: A correlation computation is required, but `estimate` is constant and ha...
! For the rsq estimates, 4 missing values were found and removed before
fitting the Gaussian process model.
! Gaussian process model: X should be in range (0, 1)
! validation: internal: A correlation computation is required, but `estimate` is constant and ha...
! For the rsq estimates, 5 missing values were found and removed before
fitting the Gaussian process model.
! Gaussian process model: X should be in range (0, 1)
! validation: internal: A correlation computation is required, but `estimate` is constant and ha...
! For the rsq estimates, 6 missing values were found and removed before
fitting the Gaussian process model.
! Gaussian process model: X should be in range (0, 1)
! validation: internal: A correlation computation is required, but `estimate` is constant and ha...
! For the rsq estimates, 7 missing values were found and removed before
fitting the Gaussian process model.
! Gaussian process model: X should be in range (0, 1)
! validation: internal: A correlation computation is required, but `estimate` is constant and ha...
! For the rsq estimates, 8 missing values were found and removed before
fitting the Gaussian process model.
! Gaussian process model: X should be in range (0, 1)
! validation: internal: A correlation computation is required, but `estimate` is constant and ha...
! For the rsq estimates, 9 missing values were found and removed before
fitting the Gaussian process model.
! Gaussian process model: X should be in range (0, 1)
! validation: internal: A correlation computation is required, but `estimate` is constant and ha...
! No improvement for 10 iterations; returning current results.

Expand Down

0 comments on commit 5b3a971

Please sign in to comment.