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

Function param_dict_to_str

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

Convert Python dictionary to string, which is passed to C API.

(data)

Source from the content-addressed store, hash-verified

132
133
134def param_dict_to_str(data):
135 """Convert Python dictionary to string, which is passed to C API."""
136 if data is None or not data:
137 return ""
138 pairs = []
139 for key, val in data.items():
140 if isinstance(val, (list, tuple, set)) or is_numpy_1d_array(val):
141 pairs.append(str(key) + '=' + ','.join(map(str, val)))
142 elif isinstance(val, string_type) or isinstance(val, numeric_types) or is_numeric(val):
143 pairs.append(str(key) + '=' + str(val))
144 elif val is not None:
145 raise TypeError('Unknown type of parameter:%s, got:%s'
146 % (key, type(val).__name__))
147 return ' '.join(pairs)
148
149
150class _TempFile(object):

Callers 7

__init__Method · 0.85
_lazy_initMethod · 0.85
constructMethod · 0.85
_update_paramsMethod · 0.85
__init__Method · 0.85
reset_parameterMethod · 0.85

Calls 5

is_numpy_1d_arrayFunction · 0.85
is_numericFunction · 0.85
typeEnum · 0.85
appendMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected