Convert a python array to c array.
(
ctype: Type[CTypeT], values: ArrayLike
)
| 228 | |
| 229 | |
| 230 | def 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 | |
| 239 | def _prediction_output( |
no outgoing calls
no test coverage detected