xorbits.numpy.broadcast#

xorbits.numpy.broadcast = <function broadcast>#

Produce an object that mimics broadcasting.

参数
  • in1 (array_like) – Input parameters.

  • in2 (array_like) – Input parameters.

  • ... (array_like) – Input parameters.

返回

b – Broadcast the input parameters against one another, and return an object that encapsulates the result. Amongst others, it has shape and nd properties, and may be used as an iterator.

返回类型

broadcast object

参见

broadcast_arrays, broadcast_to, broadcast_shapes

实际案例

Manually adding two vectors, using broadcasting:

>>> x = np.array([[1], [2], [3]])  
>>> y = np.array([4, 5, 6])  
>>> b = np.broadcast(x, y)  
>>> out = np.empty(b.shape)  
>>> out.flat = [u+v for (u,v) in b]  
>>> out  
array([[5.,  6.,  7.],
       [6.,  7.,  8.],
       [7.,  8.,  9.]])

Compare against built-in broadcasting:

>>> x + y  
array([[5, 6, 7],
       [6, 7, 8],
       [7, 8, 9]])

警告

This method has not been implemented yet. Xorbits will try to execute it with numpy.

This docstring was copied from numpy.