0 votes
in Python by
explain numpy.broadcast_arrays() in Python

1 Answer

0 votes
by

numpy.broadcast_arrays() in Python

The numpy.broadcast_arrays() function broadcasts any number of arrays against each other.

Syntax

numpy.broadcast_arrays(*args, **kwargs)

Parameter

 The numpy.broadcast_arrays() function has two parameters which are as follows:

`*args`: This parameter represents the arrays to broadcast.

subok: It is an optional parameter which take Boolean values. If it takes ‘True’ as a parameter, then sub-classes will be passed-through, else the returned arrays will be forced to be a base-class array (default).

Return

This function returns a broadcasted list of arrays. These arrays are views on the original arrays. It is typically not contiguous. 

Example 1

#Python Program explaining
#numpy.broadcast_arrays() function
import numpy as np
y = np.array([[1],[2],[3]])
x = np.array([[1,2,3]])
print ('Applying the broadcast_arrays() function:')
print (np.broadcast_arrays(x, y))

Output

Applying the broadcast_to function:
[array([[1, 2, 3],
[1, 2, 3],
[1, 2, 3]]), array([[1, 1, 1],
[2, 2, 2],
[3, 3, 3]])]

Related questions

0 votes
asked May 19, 2022 in Python by john ganales
0 votes
asked May 19, 2022 in Python by john ganales
...