I am trying to understand how nditer(ops, order='K') handles C and F
order. In the documentation it states
"âKâ means as close to the order the array elements appear in memory as
possible"
a = np.array([[1, 2], [3, 4]], order="C")
b = np.array([[1, 2], [3, 4]], order="F")
[v for v in np.nditer([a], order='K')]
[array(1), array(2), array(3), array(4)]
[v for v in np.nditer([b], order='K')]
[array(1), array(3), array(2), array(4)]
[v for v in np.nditer([a,b], order='K')]
[(array(1), array(1)), (array(2), array(2)), (array(3), array(3)),
(array(4), array(4))]
The result for np.nditer([b], order='K') seems to be wrong. Could someone
confirm this is an issue or explain what is going on?
In this example, elements of a and b are being matched up according to
their array indices, and then the iteration order is chosen according to
the 'K' rule. The array a suggests to go in 'C' order, while the array b
suggests to go in 'F' order. When there's a conflict/ambiguity such as
this, it's resolved in the direction of 'C' order. If it were to go through
a and b in each individual 'K' order, the elements wouldn't be paired
up/broadcast together, which is the whole point of iterating over multiple
arrays via the nditer.
-Mark
Matti
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion