functions.py 文件源码

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

项目:decode 作者: deshima-dev 项目源码 文件源码
def slicewhere(condition):
    """Return slices of regions that fulfill condition.

    Example:
        >>> cond = [False, True, True, False, False, True, False]
        >>> fm.utils.slicewhere(cond)
        [slice(1L, 3L, None), slice(5L, 6L, None)]

    Args:
        condition (numpy.ndarray): Array of booleans.

    Returns:
        slices (list of slice): List of slice objects.
    """
    return [region[0] for region in ndimage.find_objects(ndimage.label(condition)[0])]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号