Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
fix bugs in predict() and validate() when linked emulator was built with 'validate' mode.
  • Loading branch information
mingdeyu committed Nov 14, 2024
1 parent d3da50b commit 4184665
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/prediction.R
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ predict.lgp <- function(object, x, method = NULL, full_layer = FALSE, sample_siz
}
if ( !inherits(object,"lgp") ) stop("'object' must be an instance of the 'lgp' class.", call. = FALSE)
if ( "metadata" %in% names(object$specs) ){
if ( !("emulator_obj" %in% names(object)) ){
stop("'object' is not in activation mode for predictions. Please set `mode = 'activate'` in `lgp()` to build the emulator.", call. = FALSE)
}
if ( !is.matrix(x)&!is.vector(x) ) stop("'x' must be a vector or a matrix.", call. = FALSE)
x <- unname(x)
global_dim <- unique(subset(object$specs$struc, object$specs$struc[["From_Emulator"]] == "Global")$From_Output)
Expand Down
6 changes: 6 additions & 0 deletions R/validation.R
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,12 @@ validate.lgp <- function(object, x_test = NULL, y_test = NULL, method = NULL, sa
}
#check class
if ( !inherits(object,"lgp") ) stop("'object' must be an instance of the 'lgp' class.", call. = FALSE)

if ( "metadata" %in% names(object$specs) ){
if ( !("emulator_obj" %in% names(object)) ){
stop("'object' is not in activation mode for validations. Please set `mode = 'activate'` in `lgp()` to build the emulator.", call. = FALSE)
}
}
#check core number
if( !is.null(cores) ) {
cores <- as.integer(cores)
Expand Down

0 comments on commit 4184665

Please sign in to comment.