python类jit()的实例源码

Launch_Manager.py 文件源码 项目:KRPC 作者: BevoLJ 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def insertion_pitch(self):
        _circ_dv = self.circ_dv()
        _t_ap_dv = self.target_apoapsis_speed_dv()
        _m = np.rad2deg(self.mean_anomaly())
        _burn_time = self.maneuver_burn_time(self.circ_dv())

        @jit(nopython=True)
        def pitch_calcs_low():
                return (_t_ap_dv * (_circ_dv / 1000)) + (_m - (180 - (_burn_time / 6)))

        @jit(nopython=True)
        def pitch_calcs_high():
                return (_t_ap_dv * (_circ_dv / 1000)) + (_m - 180)

        # if self.parking_orbit_alt <= 250000: return pitch_calcs_low()
        # else: return pitch_calcs_high()
        return pitch_calcs_high()
Launch_Manager.py 文件源码 项目:KRPC 作者: BevoLJ 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def gravity_pitch(self):
        _t_ap_dv = self.target_apoapsis_speed_dv()
        _speed = self.vessel_sur_speed()
        _circ_dv = self.circ_dv()

        @jit(nopython=True)
        def pitch_calcs():
            _pitch = (90 - ((1 + (_circ_dv / 7400)) * np.sqrt(_speed))) + (_t_ap_dv / (2 - (_circ_dv / 7400)))
            return _pitch

        return pitch_calcs()
Launch_Manager.py 文件源码 项目:KRPC 作者: BevoLJ 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def gravity_pitch(self):
        _t_ap_dv = self.target_apoapsis_speed_dv()
        _speed = self.vessel_sur_speed()
        _circ_dv = self.circ_dv()

        @jit(nopython=True)
        def pitch_calcs():
            _pitch = (90 - ((1 + (_circ_dv / 7400)) * np.sqrt(_speed))) + (_t_ap_dv / (2 - (_circ_dv / 7400)))
            return _pitch

        return pitch_calcs()
Launch_Manager.py 文件源码 项目:KRPC 作者: BevoLJ 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def gravity_pitch(self):
        _t_ap_dv = self.target_apoapsis_speed_dv()
        _speed = self.vessel_sur_speed()

        @jit(nopython=True)
        def pitch_calcs():
            _pitch = (85 - (1.45 * np.sqrt(_speed))) + (_t_ap_dv / 2)
            return _pitch

        return pitch_calcs()
util.py 文件源码 项目:sympl 作者: mcgibbon 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def jit(signature_or_function=None, **kwargs):
        if signature_or_function is None:
            return lambda x: x
        else:
            return signature_or_function
queries.py 文件源码 项目:coquery 作者: gkunter 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def jit(f):
        def inner(f, *args):
            return f(*args)
        return lambda *args: inner(f, *args)
__init__.py 文件源码 项目:hpat 作者: IntelLabs 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def jit(signature_or_function=None, **options):
    from .compiler import add_hpat_stages
    # set nopython by default
    if 'nopython' not in options:
        options['nopython'] = True
    #options['parallel'] = True
    options['parallel'] =  { 'comprehension': True,
     'setitem':       False,  # FIXME: support parallel setitem
     'reduction':     True,
     'numpy':         True,
     'stencil':       True,
     'fusion':        True,
    }
    return numba.jit(signature_or_function, user_pipeline_funcs=[add_hpat_stages], **options)
Launch_Manager.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def gravity_pitch(self):
        _t_ap_dv = self.target_apoapsis_speed_dv()
        _speed = self.vessel_sur_speed()
        _circ_dv = self.circ_dv()

        @jit(nopython=True)
        def pitch_calcs():
            _pitch = (90 - ((1 + (_circ_dv / 7400)) * np.sqrt(_speed))) + (_t_ap_dv / (2 - (_circ_dv / 7400)))
            return _pitch

        return pitch_calcs()
spc_numba1.py 文件源码 项目:py4science 作者: pyjbooks 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def mult_abs_numpy(x, y):
    return np.abs(x*y)


# @jit????????????
video_renderers.py 文件源码 项目:vizgen 作者: uva-graphics 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def render(self, path_to_frame):
        """This renders the frame at path_to_frame

        It will time only the rendering (no I/O), log the time, and write the 
        output image to disk.
        """

        input_img = util.read_img(path_to_frame)
        output_img = np.zeros(input_img.shape)

        # load module
        sys.path.append("../../apps/blur_one_stage")
        import blur_one_stage
        sys.path.remove("../../apps/blur_one_stage")

        # this is equivalent to using the @jit function decorator:
        jitted_func = numba.jit(blur_one_stage.gaussian_blur)

        t1 = time.time()
        jitted_func(input_img, output_img)
        t2 = time.time()

        print("Elapsed time: %f" % (t2 - t1))

        output_filename = path_to_frame.split(os.sep)[-1]
        util.write_img(output_img, 
            os.path.join(self.output_directory, output_filename))

        # append timing data to log file:
        with open(self.log_filename, "a") as f:
            f.write("%s, %f, %f\n" % (
                os.path.join(self.output_directory, output_filename), 
                t2 - t1, 
                1./(t2 - t1)))
image_manipulation.py 文件源码 项目:pyglitch 作者: giofusco 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def rescale_image(X):
    """rescales the RGB values back to 0-255 in the image (useful after especially applying audio filters)"""
    I = X.copy()
    if (I.min() < 0 or I.max() > 255):
        I = (I - I.min()) * (255 / (I.max() - I.min()))
        I = I.round()
    return I.astype(np.uint8)


# TODO: speed up with jit?
input_encoders_numba.py 文件源码 项目:LSTM-and-maxlayer-for-SNV-based-phenotype-prediction 作者: widmi 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def encode_inplace_jit(self, nr_samples, lengths, out):
        """ Need to use this function to call the jit compiled function, as
            class support via numba is disabled sice 0.12"""
        encode_triangles_inplace_jit(n_binary_bits=self.n_binary_bits,
                             ticker_steps=self.ticker_steps, 
                             n_inputnodes=self.n_inputnodes,
                             node_range=self.node_range,
                             nr_samples=nr_samples, lengths=lengths, out=out, 
                             out_uint=out.view(np.uint32))
input_encoders_numba.py 文件源码 项目:LSTM-and-maxlayer-for-SNV-based-phenotype-prediction 作者: widmi 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def encode_inplace_jit(self, nr_samples, lengths, out):
        """ Need to use this function to call the jit compiled function, as
            class support via numba is disabled sice 0.12"""
        encode_overlapping_binary_inplace_jit(ticker_steps=self.ticker_steps, 
                             n_inputnodes=self.n_inputnodes,
                             nr_samples=nr_samples, lengths=lengths, out=out, 
                             out_uint=out.view(np.uint32))
input_encoders_numba.py 文件源码 项目:LSTM-and-maxlayer-for-SNV-based-phenotype-prediction 作者: widmi 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def encode_jit(self, nr_samples, lengths, out, positions):
        """ Need to use this function to call the jit compiled function, as
            class support via numba is disabled sice 0.12"""
        encode_overlapping_binary_jit(n_inputnodes=self.data_nodes,
                             nr_samples=nr_samples, lengths=lengths, out=out, 
                             positions=np.uint32(positions))
numba_board.py 文件源码 项目:ChessAI 作者: SamRagusa 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def any(iterable):
    for element in iterable:
        return True
    return False






# @jit(BoardState.class_type.instance_type(BoardState.class_type.instance_type), nopython=True)
conv1d.py 文件源码 项目:DBQA-KBQA 作者: Lucien-qiang 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def make_thunk(self, node, storage_map, compute_map, no_recycling):
    in1_type = getattr(numba, node.inputs[0].dtype)
    in2_type = getattr(numba, node.inputs[1].dtype)
    out_type = getattr(numba, node.outputs[0].dtype)
    self.numba_fct = numba.jit(out_type[:, :](in1_type[:, :], in2_type[:, :]))(convolve1d_2D_numpy)
    # self.numba_fct = convolve1d_2D_numpy
    return super(Convolve1d, self).make_thunk(
        node, storage_map, compute_map, no_recycling)
conv1d.py 文件源码 项目:DBQA-KBQA 作者: Lucien-qiang 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def make_thunk(self, node, storage_map, compute_map, no_recycling):
        in1_type = getattr(numba, node.inputs[0].dtype)
        in2_type = getattr(numba, node.inputs[1].dtype)
        out_type = getattr(numba, node.outputs[0].dtype)
        self.numba_fct = numba.jit(out_type[:,:,:,:](in1_type[:,:,:,:],
                                   in2_type[:,:,:,:]))(convolve1d_4D_numpy)
        # self.numba_fct = convolve1d_4D_numpy
        return super(Convolve1d_4D, self).make_thunk(
            node, storage_map, compute_map, no_recycling)
kernels.py 文件源码 项目:formation_python2017 作者: gouarin 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def convolve_mean3_gu(image, index, out_image):
    nx, ny, nk = image.shape
    for j in range(1,ny-1):
        for k in range(3):
            out_image[j-1, k] = 0.25*(image[index[0]-1,j,k]+image[index[0]+1,j,k]+image[index[0],j-1,k]+image[index[0],j+1,k])

#@numba.jit
#def convolve_mean2(image):
#    height, width = image.shape
#    out_image = np.empty((height-2, width-2))
#    i = np.arange(1, height-1)
#    j = np.arange(1, width-1)
#    convolve_mean2_gu(image, i[:, np.newaxis], j[np.newaxis, :], out_image)
#    return out_image
conv1d.py 文件源码 项目:DEEP-CLICK-MODEL 作者: THUIR 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def make_thunk(self, node, storage_map, compute_map, no_recycling):
    in1_type = getattr(numba, node.inputs[0].dtype)
    in2_type = getattr(numba, node.inputs[1].dtype)
    out_type = getattr(numba, node.outputs[0].dtype)
    self.numba_fct = numba.jit(out_type[:, :](in1_type[:, :], in2_type[:, :]))(convolve1d_2D_numpy)
    # self.numba_fct = convolve1d_2D_numpy
    return super(Convolve1d, self).make_thunk(
        node, storage_map, compute_map, no_recycling)
conv1d.py 文件源码 项目:DEEP-CLICK-MODEL 作者: THUIR 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def make_thunk(self, node, storage_map, compute_map, no_recycling):
        in1_type = getattr(numba, node.inputs[0].dtype)
        in2_type = getattr(numba, node.inputs[1].dtype)
        out_type = getattr(numba, node.outputs[0].dtype)
        self.numba_fct = numba.jit(out_type[:,:,:,:](in1_type[:,:,:,:],
                                   in2_type[:,:,:,:]))(convolve1d_4D_numpy)
        # self.numba_fct = convolve1d_4D_numpy
        return super(Convolve1d_4D, self).make_thunk(
            node, storage_map, compute_map, no_recycling)


问题


面经


文章

微信
公众号

扫码关注公众号