numpy nditer

Solutions on MaxInterview for numpy nditer by the best coders in the world

showing results for - "numpy nditer"
Maria José
09 Jan 2017
1import numpy as np
2a=np.array([[2,4,5],[3,6,7],[4,8,9]])
3print("Original array is :")
4print(a)
5print("Modified array is:")
6for x in np.nditer(a, flags = ['external_loop'],order='F'):
7        print(x)
8
Neele
02 Aug 2017
1import numpy as np
2a=np.array([2,4,5])
3print("Original array is :")
4print(a)
5print("Modified array is:")
6for x in np.nditer(a):
7       print(x)
8
Fergus
21 Jun 2018
1>>> def iter_add(x, y, out=None):
2...    addop = np.add
3...    it = np.nditer([x, y, out], [],
4...                [['readonly'], ['readonly'], ['writeonly','allocate']])
5...    with it:
6...        while not it.finished:
7...            addop(it[0], it[1], out=it[2])
8...            it.iternext()
9...        return it.operands[2]
10