Commit 9ee10754 authored by Guolin Ke's avatar Guolin Ke
Browse files

fix the error message for get_field

parent b30beb99
...@@ -379,8 +379,10 @@ Dataset <- R6Class( ...@@ -379,8 +379,10 @@ Dataset <- R6Class(
} }
# Check for info name and handle # Check for info name and handle
if (is.null(private$info[[name]]) && !lgb.is.null.handle(private$handle)) { if (is.null(private$info[[name]])) {
if (lgb.is.null.handle(private$handle)){
stop("Cannot perform getinfo before construct Dataset.")
}
# Get field size of info # Get field size of info
info_len <- 0L info_len <- 0L
info_len <- lgb.call("LGBM_DatasetGetFieldSize_R", info_len <- lgb.call("LGBM_DatasetGetFieldSize_R",
......
...@@ -986,7 +986,7 @@ class Dataset(object): ...@@ -986,7 +986,7 @@ class Dataset(object):
A numpy array with information from the Dataset. A numpy array with information from the Dataset.
""" """
if self.handle is None: if self.handle is None:
raise Exception("Cannot get %s before construct dataset" % field_name) raise Exception("Cannot get %s before construct Dataset" % field_name)
tmp_out_len = ctypes.c_int() tmp_out_len = ctypes.c_int()
out_type = ctypes.c_int() out_type = ctypes.c_int()
ret = ctypes.POINTER(ctypes.c_void_p)() ret = ctypes.POINTER(ctypes.c_void_p)()
...@@ -1144,7 +1144,7 @@ class Dataset(object): ...@@ -1144,7 +1144,7 @@ class Dataset(object):
label : numpy array label : numpy array
The label information from the Dataset. The label information from the Dataset.
""" """
if self.label is None and self.handle is not None: if self.label is None:
self.label = self.get_field('label') self.label = self.get_field('label')
return self.label return self.label
...@@ -1156,7 +1156,7 @@ class Dataset(object): ...@@ -1156,7 +1156,7 @@ class Dataset(object):
weight : numpy array weight : numpy array
Weight for each data point from the Dataset. Weight for each data point from the Dataset.
""" """
if self.weight is None and self.handle is not None: if self.weight is None:
self.weight = self.get_field('weight') self.weight = self.get_field('weight')
return self.weight return self.weight
...@@ -1168,7 +1168,7 @@ class Dataset(object): ...@@ -1168,7 +1168,7 @@ class Dataset(object):
init_score : numpy array init_score : numpy array
Init score of Booster. Init score of Booster.
""" """
if self.init_score is None and self.handle is not None: if self.init_score is None:
self.init_score = self.get_field('init_score') self.init_score = self.get_field('init_score')
return self.init_score return self.init_score
...@@ -1180,7 +1180,7 @@ class Dataset(object): ...@@ -1180,7 +1180,7 @@ class Dataset(object):
group : numpy array group : numpy array
Group size of each group. Group size of each group.
""" """
if self.group is None and self.handle is not None: if self.group is None:
self.group = self.get_field('group') self.group = self.get_field('group')
if self.group is not None: if self.group is not None:
# group data from LightGBM is boundaries data, need to convert to group size # group data from LightGBM is boundaries data, need to convert to group size
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment