MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / _TempFile

Class _TempFile

python-package/lightgbmmt/basic.py:150–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148
149
150class _TempFile(object):
151 def __enter__(self):
152 with NamedTemporaryFile(prefix="lightgbm_tmp_", delete=True) as f:
153 self.name = f.name
154 return self
155
156 def __exit__(self, exc_type, exc_val, exc_tb):
157 if os.path.isfile(self.name):
158 os.remove(self.name)
159
160 def readlines(self):
161 with open(self.name, "r+") as f:
162 ret = f.readlines()
163 return ret
164
165 def writelines(self, lines):
166 with open(self.name, "w+") as f:
167 f.writelines(lines)
168
169
170class LightGBMError(Exception):

Callers 1

predictMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected