shape_fitter.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:ms_deisotope 作者: mobiusklein 项目源码 文件源码
def find_left_intersect(vec, target_val, start_index=0):
        nearest_index = start_index
        next_index = start_index

        size = len(vec) - 1
        if next_index == size:
            return size

        next_val = vec[next_index]
        best_distance = np.abs(next_val - target_val)
        while (next_index > 0):
            next_index -= 1
            next_val = vec[next_index]
            dist = np.fabs(next_val - target_val)
            if dist < best_distance:
                best_distance = dist
                nearest_index = next_index
            if next_index == size or next_val < target_val:
                break
        return nearest_index
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号