Vectorize over the rows of an array
NumPy implements the concept of "action over a particular axis". The general function is numpy.apply_along_axis()
:
>>> numpy.apply_along_axis(sum, 1, X)
array([15, 30])
(where sum
can of course be replaced by anything).