num.py 文件源码

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

项目:pwtools 作者: elcorto 项目源码 文件源码
def inner_points_mask(points):
    """Mask array into `points` where ``points[msk]`` are all "inner" points,
    i.e. `points` with one level of edge points removed. For 1D, this is simply
    points[1:-1,:] (assuming ordered points). For ND, we calculate and remove
    the convex hull.

    Parameters
    ----------
    points : nd array (npoints, ndim)

    Returns
    -------
    msk : (npoints, ndim)
        Bool array.
    """
    msk = np.ones((points.shape[0],), dtype=bool)
    if points.shape[1] == 1:
        assert (np.diff(points[:,0]) >= 0.0).all(), ("points not monotonic")
        msk[0] = False
        msk[-1] = False
    else:
        from scipy.spatial import Delaunay
        tri = Delaunay(points)
        edge_idx = np.unique(tri.convex_hull)
        msk.put(edge_idx, False)
    return msk
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号