Fills an ndarray with a function