Commit 67ca6091 authored by Guolin Ke's avatar Guolin Ke
Browse files

explicit close file in python

parent 83a14174
...@@ -274,7 +274,9 @@ class Predictor(object): ...@@ -274,7 +274,9 @@ class Predictor(object):
predict_type, predict_type,
num_iteration, num_iteration,
c_str(tmp_pred_fname))) c_str(tmp_pred_fname)))
lines = open(tmp_pred_fname,"r").readlines() tmp_file = open(tmp_pred_fname,"r")
lines = tmp_file.readlines()
tmp_file.close()
nrow = len(lines) nrow = len(lines)
preds = [] preds = []
for line in lines: for line in lines:
...@@ -505,7 +507,11 @@ class Dataset(object): ...@@ -505,7 +507,11 @@ class Dataset(object):
return Dataset(data, label=label, max_bin=self.max_bin, reference=self, return Dataset(data, label=label, max_bin=self.max_bin, reference=self,
weight=weight, group_id=group_id, predictor=self.predictor, weight=weight, group_id=group_id, predictor=self.predictor,
silent=silent, params=params) silent=silent, params=params)
def subset(self, used_indices, params=None): def subset(self, used_indices, params=None):
"""
Get subset of current dataset
"""
used_indices = list_to_1d_numpy(used_indices, np.int32) used_indices = list_to_1d_numpy(used_indices, np.int32)
ret = Dataset(None) ret = Dataset(None)
ret.handle = ctypes.c_void_p() ret.handle = ctypes.c_void_p()
......
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