I have a Numpy array with positive and negative values. I need to apply a function to the positive numbers or zero (funcPos) and a different one to the negative numbers (funcNeg), getting the result as another array.
I know there is the numpy.where function, so I could do:
y = np.where(x >= 0, funcPos(x), funcNeg(x))
However, this applies funcPos and funcNeg to all the elements of the input array, trowing many errors in the process because those functions are not designed to deal with numbers of the wrong sign.
Do you have any suggestion on how to do this in a fast way (not using a loop)?
Many thanks,