Fix print.xgb.Booster for R (#3338)
* Fix print.xgb.Booster valid_handle should be TRUE when x$handle is NOT null * Update xgb.Booster.R Modify is.null.handle to return TRUE for NULL handle
This commit is contained in:
parent
a510e68dda
commit
b7cbec4d4b
@ -37,11 +37,14 @@ xgb.handleToBooster <- function(handle, raw = NULL) {
|
|||||||
# Check whether xgb.Booster.handle is null
|
# Check whether xgb.Booster.handle is null
|
||||||
# internal utility function
|
# internal utility function
|
||||||
is.null.handle <- function(handle) {
|
is.null.handle <- function(handle) {
|
||||||
|
if (is.null(handle)) return(TRUE)
|
||||||
|
|
||||||
if (!identical(class(handle), "xgb.Booster.handle"))
|
if (!identical(class(handle), "xgb.Booster.handle"))
|
||||||
stop("argument type must be xgb.Booster.handle")
|
stop("argument type must be xgb.Booster.handle")
|
||||||
|
|
||||||
if (is.null(handle) || .Call(XGCheckNullPtr_R, handle))
|
if (.Call(XGCheckNullPtr_R, handle))
|
||||||
return(TRUE)
|
return(TRUE)
|
||||||
|
|
||||||
return(FALSE)
|
return(FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -537,7 +540,7 @@ xgb.ntree <- function(bst) {
|
|||||||
print.xgb.Booster <- function(x, verbose = FALSE, ...) {
|
print.xgb.Booster <- function(x, verbose = FALSE, ...) {
|
||||||
cat('##### xgb.Booster\n')
|
cat('##### xgb.Booster\n')
|
||||||
|
|
||||||
valid_handle <- is.null.handle(x$handle)
|
valid_handle <- !is.null.handle(x$handle)
|
||||||
if (!valid_handle)
|
if (!valid_handle)
|
||||||
cat("Handle is invalid! Suggest using xgb.Booster.complete\n")
|
cat("Handle is invalid! Suggest using xgb.Booster.complete\n")
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user