def c_int_array(data):
    """Get pointer of int numpy array / list."""
    if is_1d_list(data):
        data = np.array(data, copy=False)
    if is_numpy_1d_array(data):
        data = convert_from_sliced_object(data)
        assert data.flags.c_contiguous
        if data.dtype == np.int32:
            ptr_data = data.ctypes.data_as(ctypes.POINTER(ctypes.c_int32))
            type_data = C_API_DTYPE_INT32
        elif data.dtype == np.int64:
            ptr_data = data.ctypes.data_as(ctypes.POINTER(ctypes.c_int64))
            type_data = C_API_DTYPE_INT64
        else:
            raise TypeError("Expected np.int32 or np.int64, met type({})"
                            .format(data.dtype))
    else:
        raise TypeError("Unknown type({})".format(type(data).__name__))
    return (ptr_data, type_data, data)
def c_int_array ( data ) : if is_1d_list ( data ) : data = np . array ( data , copy = False ) if is_numpy_1d_array ( data ) : data = convert_from_sliced_object ( data ) assert data . flags . c_contiguous if data . dtype == np . int32 : ptr_data = data . ctypes . data_as ( ctypes . POINTER ( ctypes . c_int32 ) ) type_data = C_API_DTYPE_INT32 elif data . dtype == np . int64 : ptr_data = data . ctypes . data_as ( ctypes . POINTER ( ctypes . c_int64 ) ) type_data = C_API_DTYPE_INT64 else : raise TypeError ( "Expected np.int32 or np.int64, met type({})" . format ( data . dtype ) ) else : raise TypeError ( "Unknown type({})" . format ( type ( data ) . __name__ ) ) return ( ptr_data , type_data , data )
Get pointer of int numpy array / list.