for direction in (1, -1):
    for i in range(section):
        yield i * (amplitude / section) * direction
for i in range(section):
    yield (amplitude - i * (amplitude / section)) * direction
Triangle wave shaped array in Python