MCPcopy Create free account
hub / github.com/dmlc/xgboost / c_array

Function c_array

python-package/xgboost/core.py:230–236  ·  view source on GitHub ↗

Convert a python array to c array.

(
    ctype: Type[CTypeT], values: ArrayLike
)

Source from the content-addressed store, hash-verified

228
229
230def c_array(
231 ctype: Type[CTypeT], values: ArrayLike
232) -> Union[ctypes.Array, ctypes._Pointer]:
233 """Convert a python array to c array."""
234 if isinstance(values, np.ndarray) and values.dtype.itemsize == ctypes.sizeof(ctype):
235 return values.ctypes.data_as(ctypes.POINTER(ctype))
236 return (ctype * len(values))(*values)
237
238
239def _prediction_output(

Callers 4

sliceMethod · 0.85
__init__Method · 0.85
__setstate__Method · 0.85
eval_setMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected