bugfix booster.check
This commit is contained in:
parent
23e46b7fa5
commit
98618646f6
@ -87,8 +87,12 @@ xgb.handleToBooster <- function(handle)
|
|||||||
# Check whether an xgb.Booster object is complete
|
# Check whether an xgb.Booster object is complete
|
||||||
xgb.Booster.check <- function(bst, saveraw = TRUE)
|
xgb.Booster.check <- function(bst, saveraw = TRUE)
|
||||||
{
|
{
|
||||||
if (is.null(bst$handle)) {
|
isnull <- is.null(bst$handle)
|
||||||
bst$handle <- xgb.load(bst$raw)
|
if (!isnull) {
|
||||||
|
isnull <- .Call("XGCheckNullPtr_R", bst$handle, PACKAGE="xgboost")
|
||||||
|
}
|
||||||
|
if (isnull) {
|
||||||
|
bst$handle <- xgb.Booster(modelfile = bst$raw)
|
||||||
} else {
|
} else {
|
||||||
if (is.null(bst$raw) && saveraw)
|
if (is.null(bst$raw) && saveraw)
|
||||||
bst$raw <- xgb.save.raw(bst$handle)
|
bst$raw <- xgb.save.raw(bst$handle)
|
||||||
|
|||||||
@ -59,6 +59,9 @@ inline void _WrapperEnd(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
SEXP XGCheckNullPtr_R(SEXP handle) {
|
||||||
|
return ScalarLogical(R_ExternalPtrAddr(handle) == NULL);
|
||||||
|
}
|
||||||
void _DMatrixFinalizer(SEXP ext) {
|
void _DMatrixFinalizer(SEXP ext) {
|
||||||
if (R_ExternalPtrAddr(ext) == NULL) return;
|
if (R_ExternalPtrAddr(ext) == NULL) return;
|
||||||
XGDMatrixFree(R_ExternalPtrAddr(ext));
|
XGDMatrixFree(R_ExternalPtrAddr(ext));
|
||||||
|
|||||||
@ -11,6 +11,12 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
/*!
|
||||||
|
* \brief check whether a handle is NULL
|
||||||
|
* \param handle
|
||||||
|
* \return whether it is null ptr
|
||||||
|
*/
|
||||||
|
SEXP XGCheckNullPtr_R(SEXP handle);
|
||||||
/*!
|
/*!
|
||||||
* \brief load a data matrix
|
* \brief load a data matrix
|
||||||
* \param fname name of the content
|
* \param fname name of the content
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user