Apply Function In Numpy Over 1 D Array