def is_alternating_signs(a):
    return numpy.all(numpy.abs(numpy.diff(numpy.sign(a))) == 2)
print(is_alternating_signs([1, -1, 1, -1, 1]))
print(is_alternating_signs([-1, 1, -1, 1, -1]))
print(is_alternating_signs([1, -1, 1, -1, -1]))
Detect alternating signs