dask.array.coarsen
dask.array.coarsen¶
- dask.array.coarsen(reduction, x, axes, trim_excess=False, **kwargs)[源代码]¶
通过对固定大小的邻域应用缩减来粗化数组
- 参数
- reduction: 函数
类似 np.sum, np.mean 等函数…
- x: np.ndarray
要粗化的数组
- axes: dict
轴到粗化因子的映射
示例
>>> x = np.array([1, 2, 3, 4, 5, 6]) >>> coarsen(np.sum, x, {0: 2}) array([ 3, 7, 11]) >>> coarsen(np.max, x, {0: 3}) array([3, 6])
提供每个维度的比例字典
>>> x = np.arange(24).reshape((4, 6)) >>> x array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23]])
>>> coarsen(np.min, x, {0: 2, 1: 3}) array([[ 0, 3], [12, 15]])
你必须避免明确地使用过多的元素
>>> x = np.array([1, 2, 3, 4, 5, 6, 7, 8]) >>> coarsen(np.min, x, {0: 3}, trim_excess=True) array([1, 4])