I would like to test every single element of "z", with the "if else" condition and return desired equation. My implementation is resulting with an error. I tried "z.all" and "z.any" functions but these two are converting "z" to a boolean array. I do not want z as boolean array. How can I do this, while z remain as a numpy array?
z is a numpy array and its shape is (10610, ))
def function(z):
alpha = 1
if (z < 0):
return -alpha * z
elif (0 <= z <= 1):
return (3 * z ** 3) - (4 * z ** 2) + (2 * z)
else:
return z