B xsz _broadcast_to..z4all elements of broadcast shape must be non-negativeZ reduce_okZ readwritereadonlyZ multi_indexZrefs_okZ zerosize_okC)rZop_flagsZ itershapeorderrT) riterablerrr ValueErroranyrrZnditerZitviewsr) rrrr%Zneeds_writeableZextrasZop_flag broadcastresultr r r _broadcast_toss     r-cCst|||ddS)aBroadcast an array to a new shape. Parameters ---------- array : array_like The array to broadcast. shape : tuple The shape of the desired array. subok : bool, optional If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (default). Returns ------- broadcast : array 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. Raises ------ ValueError If the array is not compatible with the new shape according to NumPy's broadcasting rules. Notes ----- .. versionadded:: 1.10.0 Examples -------- >>> x = np.array([1, 2, 3]) >>> np.broadcast_to(x, (3, 3)) array([[1, 2, 3], [1, 2, 3], [1, 2, 3]]) T)rr%)r-)rrrr r r rs&cGsb|sdStj|dd}x@tdt|dD],}td|j}tj|f|||d}q,W|jS)ztReturns the shape of the arrays that would result from broadcasting the supplied arrays against each other. r N r)rr+rangelenrr)argsbposr r r _broadcast_shapes  r5csn|dd|r&td|dfdd|D}t|tfdd|DrZ|Sfd d|DS) a Broadcast any number of arrays against each other. Parameters ---------- `*args` : array_likes The arrays to broadcast. subok : bool, optional If True, then sub-classes will be passed-through, otherwise the returned arrays will be forced to be a base-class array (default). Returns ------- broadcasted : list of arrays These arrays are views on the original arrays. They are typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. If you need to write to the arrays, make copies first. Examples -------- >>> x = np.array([[1,2,3]]) >>> y = np.array([[1],[2],[3]]) >>> np.broadcast_arrays(x, y) [array([[1, 2, 3], [1, 2, 3], [1, 2, 3]]), array([[1, 1, 1], [2, 2, 2], [3, 3, 3]])] Here is a useful idiom for getting contiguous copies instead of non-contiguous views. >>> [np.array(a) for a in np.broadcast_arrays(x, y)] [array([[1, 2, 3], [1, 2, 3], [1, 2, 3]]), array([[1, 1, 1], [2, 2, 2], [3, 3, 3]])] rFz:broadcast_arrays() got an unexpected keyword argument {!r}rcsg|]}tj|ddqS)F)rr)rr)r"_m)rr r sz$broadcast_arrays..c3s|]}|jkVqdS)N)r)r"r)rr r r$sz#broadcast_arrays..csg|]}t|ddqS)F)rr%)r-)r"r)rrr r r7s)pop TypeErrorformatkeysr5all)r2kwargsr )rrr rs0  )NNFT)F)rZ __future__rrrZnumpyr__all__objectrrr!r-rr5rr r r r s  M )