Im trying to understand the following code:
A = np.arange(3).reshape(3,1)
B = np.arange(3).reshape(1,3)
it = np.nditer([A,B,None])
for x,y,z in it: z[...] = x + y
print(it.operands[2])
And I can't figure out what [...] is doing.
Im trying to understand the following code:
A = np.arange(3).reshape(3,1)
B = np.arange(3).reshape(1,3)
it = np.nditer([A,B,None])
for x,y,z in it: z[...] = x + y
print(it.operands[2])
And I can't figure out what [...] is doing.
 
    
    z is an element of your output. The most common usecase to modify it is via this statement z[...] = # something. The ... is an ellipsis.
What your code does is basically iterate over A and B in a nested forloop, and write the output to the third element of the nditer object.Much like the below code.
To read more about ellipsis, see https://docs.python.org/dev/library/constants.html#Ellipsis
To read more about python iter output, see https://numpy.org/doc/stable/reference/arrays.nditer.html 
Especially Iterator-Allocated Output Arrays section
