xorbits.numpy.broadcast_to#

xorbits.numpy.broadcast_to(tensor, shape)[源代码]#

Broadcast an array to a new shape.

参数
  • array (array_like (Not supported yet)) – The array to broadcast.

  • shape (tuple or int) – The shape of the desired array. A single integer i is interpreted as (i,).

  • subok (bool, optional (Not supported yet)) – If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (default).

返回

broadcast – A readonly view on the original array with the given shape. It is typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location.

返回类型

array

引发

ValueError – If the array is not compatible with the new shape according to NumPy’s broadcasting rules.

参见

broadcast, broadcast_arrays, broadcast_shapes

提示

1.10.0(numpy) 新版功能.

实际案例

>>> x = np.array([1, 2, 3])  
>>> np.broadcast_to(x, (3, 3))  
array([[1, 2, 3],
       [1, 2, 3],
       [1, 2, 3]])
tensorarray_like

The tensor to broadcast.

This docstring was copied from numpy.