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

muffle "X should be in range (0, 1)" warning #788

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i chose to do one call to withCallingHandlers() around the whole if instead of two because it felt better.

no strong opinion either way

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
Loading