toolbox_extended.py 文件源码

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

项目:Codes 作者: SP2RC-Coding-Club 项目源码 文件源码
def check(value, value_list, difference):
    n = True
    if len(value_list) == 0:
        value_list.append(value)
    else:
        for x in value_list:
            if np.abs(np.real(x) - np.real(value)) < difference and \
               np.abs(np.imag(x) - np.imag(value)) < difference:
                   n = False
            else:
                pass
        if n == True:
            value_list.append(value)
    return value_list

# This function converts a list of lists into a numpy array. It only takes the
# list of lists as input, and returns the array as output. If the lists inside 
# the list are of unequal lengths, it fills up the lines with None so that all 
# lines in the output array are of equal length.
# Example input:
# a = [[1,3,4], [2,1], [2,3,4,7]]
# Output:
# array([[1, 3, 4, None],
#        [2, 1, None, None],
#        [2, 3, 4, 7]], dtype=object)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号