utils.py 文件源码

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

项目:tslearn 作者: rtavenar 项目源码 文件源码
def _arraylike_copy(arr):
    """Duplicate content of arr into a numpy array.

     Examples
     --------
     >>> X_npy = numpy.array([1, 2, 3])
     >>> numpy.alltrue(_arraylike_copy(X_npy) == X_npy)
     True
     >>> _arraylike_copy(X_npy) is X_npy
     False
     >>> numpy.alltrue(_arraylike_copy([1, 2, 3]) == X_npy)
     True
     """
    if type(arr) != numpy.ndarray:
        return numpy.array(arr)
    else:
        return arr.copy()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号