parcnsdl.py 文件源码

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

项目:sporco 作者: bwohlberg 项目源码 文件源码
def mpraw_as_np(shape, dtype):
    """Construct a numpy array of the specified shape and dtype for which the
    underlying storage is a multiprocessing RawArray in shared memory.

    Parameters
    ----------
    shape : tuple
      Shape of numpy array
    dtype : data-type
      Data type of array

    Returns
    -------
    arr : ndarray
      Numpy array
    """

    sz = int(np.product(shape))
    csz = sz * np.dtype(dtype).itemsize
    raw = mp.RawArray('c', csz)
    return np.frombuffer(raw, dtype=dtype, count=sz).reshape(shape)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号