(assign, lhs, rhs)
return nodes
translate np.fromfile() to native
translate np.fromfile() to native
translate np . fromfile () to native
def _handle_np_fromfile(assign, lhs, rhs):
    """translate np.fromfile() to native
    """
    # TODO: dtype in kws
    if len(rhs.args) != 2:  # pragma: no cover
        raise ValueError(
            "np.fromfile(): file name and dtype expected")

    # FIXME: import here since hio has hdf5 which might not be available
    from .. import hio
    from .. import transport_seq as transport

    import llvmlite.binding as ll
    ll.add_symbol('get_file_size', transport.get_file_size)
    ll.add_symbol('file_read', hio.file_read)
    ll.add_symbol('file_read_parallel', transport.file_read_parallel)
    _fname = rhs.args[0]
    _dtype = rhs.args[1]

    def fromfile_impl(fname, dtype):
        size = get_file_size(fname)
        dtype_size = get_dtype_size(dtype)
        A = np.empty(size // dtype_size, dtype=dtype)
        file_read(fname, A, size)
        read_arr = A

    f_block = compile_to_numba_ir(fromfile_impl,
                                  {'np': np,
                                   'get_file_size': get_file_size,
                                   'file_read': file_read,
                                   'get_dtype_size': get_dtype_size}).blocks.popitem()[1]
    replace_arg_nodes(f_block, [_fname, _dtype])
    nodes = f_block.body[:-3]  # remove none return
    nodes[-1].target = lhs
    return nodes
def _handle_np_fromfile ( assign , lhs , rhs ) : # TODO: dtype in kws if len ( rhs . args ) != 2 : # pragma: no cover raise ValueError ( "np.fromfile(): file name and dtype expected" ) # FIXME: import here since hio has hdf5 which might not be available from . . import hio from . . import transport_seq as transport import llvmlite . binding as ll ll . add_symbol ( 'get_file_size' , transport . get_file_size ) ll . add_symbol ( 'file_read' , hio . file_read ) ll . add_symbol ( 'file_read_parallel' , transport . file_read_parallel ) _fname = rhs . args [ 0 ] _dtype = rhs . args [ 1 ] def fromfile_impl ( fname , dtype ) : size = get_file_size ( fname ) dtype_size = get_dtype_size ( dtype ) A = np . empty ( size // dtype_size , dtype = dtype ) file_read ( fname , A , size ) read_arr = A f_block = compile_to_numba_ir ( fromfile_impl , { 'np' : np , 'get_file_size' : get_file_size , 'file_read' : file_read , 'get_dtype_size' : get_dtype_size } ) . blocks . popitem ( ) [ 1 ] replace_arg_nodes ( f_block , [ _fname , _dtype ] ) nodes = f_block . body [ : - 3 ] # remove none return nodes [ - 1 ] . target = lhs return nodes