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

Function c_int_array

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

Get pointer of int numpy array / list.

(data)

Source from the content-addressed store, hash-verified

283
284
285def c_int_array(data):
286 """Get pointer of int numpy array / list."""
287 if is_1d_list(data):
288 data = np.array(data, copy=False)
289 if is_numpy_1d_array(data):
290 data = convert_from_sliced_object(data)
291 assert data.flags.c_contiguous
292 if data.dtype == np.int32:
293 ptr_data = data.ctypes.data_as(ctypes.POINTER(ctypes.c_int32))
294 type_data = C_API_DTYPE_INT32
295 elif data.dtype == np.int64:
296 ptr_data = data.ctypes.data_as(ctypes.POINTER(ctypes.c_int64))
297 type_data = C_API_DTYPE_INT64
298 else:
299 raise TypeError("Expected np.int32 or np.int64, met type({})"
300 .format(data.dtype))
301 else:
302 raise TypeError("Unknown type({})".format(type(data).__name__))
303 return (ptr_data, type_data, data) # return `data` to avoid the temporary copy is freed
304
305
306def _get_bad_pandas_dtypes(dtypes):

Callers 6

inner_predictMethod · 0.85
__pred_for_cscMethod · 0.85
__init_from_csrMethod · 0.85
__init_from_cscMethod · 0.85
set_fieldMethod · 0.85
refitMethod · 0.85

Calls 6

is_1d_listFunction · 0.85
is_numpy_1d_arrayFunction · 0.85
typeEnum · 0.85
arrayMethod · 0.80
formatMethod · 0.80

Tested by

no test coverage detected