Say I have a list (or numpy.array) of (row, col) coordinates, e.g.:
[(0, 0), (1, 1), (0, 0)]
I'd like to build the 2x2 array like this:
2 0
0 1
where each of the listed coordinates is counted and put in the right place in the array. I.e. (0, 0) appears twice, so a[0, 0] == 2.
I know I can build this by iterating and poking the array for each element, but I wanted to check if there is any support in numpy regarding building the array like this, mostly for performance reasons. Can you point me in the right direction if so?
Also, is there a reduce-like functionality along the above lines? I.e. do new = f(acc, el) instead of new = acc + el.