I think a better way is to use np.gradient(x). If you have any change in sign in the gradient a turning point has occurred. A 0 is a point of inflection. Tell me if you need more clarification.