vector_shortcuts.py 文件源码

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

项目:blmath 作者: bodylabs 项目源码 文件源码
def unpad(matrix):
    '''
    Strip off a column (e.g. of ones). Transform from:
        array([[1., 2., 3., 1.],
               [2., 3., 4., 1.],
               [5., 6., 7., 1.]])
    to:
        array([[1., 2., 3.],
               [2., 3., 4.],
               [5., 6., 7.]])

    '''
    if matrix.ndim != 2 or matrix.shape[1] != 4:
        raise ValueError("Invalid shape %s: unpad expects nx4" % (matrix.shape,))
    if not all(matrix[:, 3] == 1.):
        raise ValueError('Expected a column of ones')
    return np.delete(matrix, 3, axis=1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号