building numpy arrays with regular structure
Seb
spluque at gmail.com
Fri Dec 16 22:56:12 EST 2016
Hello,
Is there an easier way to write a numpy array with a regular structure?
For example, an array with [0, 1] along the diagnal of one of the array
dimensions, and zero elsewhere:
zz = np.array([[[0, 1], [0, 0], [0, 0]],
[[0, 0], [0, 1], [0, 0]],
[[0, 0], [0, 0], [0, 1]]])
This one is not so big, but if it were, there must be a way to code this
properly.
Thanks,
--
Seb
More information about the Python-list
mailing list