Utilities/maths/math_utils.py
def average_angles(angles):
    """Average (mean) of angles

    Return the average of an input sequence of angles. The result is between
    ``0`` and ``2 * math.pi``.
    If the average is not defined (e.g. ``average_angles([0, math.pi]))``,
    a ``ValueError`` is raised.
    """

    x = sum(math.cos(a) for a in angles)
    y = sum(math.sin(a) for a in angles)

    if x == 0 and y == 0:
        raise ValueError(
            "The angle average of the inputs is undefined: %r" % angles)

    # To get outputs from -pi to +pi, delete everything but math.atan2() here.
    return math.fmod(math.atan2(y, x) + 2 * math.pi, 2 * math.pi)
Average (mean) of angles

    Return the average of an input sequence of angles. The result is between
    ``0`` and ``2 * math.pi``.
    If the average is not defined (e.g. ``average_angles([0, math.pi]))``,
    a ``ValueError`` is raised.
    
Average (mean) of angles
Return the average of an input sequence of angles.
Average ( mean ) of angles Return the average of an input sequence of angles .
def average_angles(angles):
    x = sum(math.cos(a) for a in angles)
    y = sum(math.sin(a) for a in angles)
    if x == 0 and y == 0:
        raise ValueError(
            "The angle average of the inputs is undefined: %r" % angles)
    return math.fmod(math.atan2(y, x) + 2 * math.pi, 2 * math.pi)
def average_angles ( angles ) : x = sum ( math . cos ( a ) for a in angles ) y = sum ( math . sin ( a ) for a in angles ) if x == 0 and y == 0 : raise ValueError ( "The angle average of the inputs is undefined: %r" % angles ) return math . fmod ( math . atan2 ( y , x ) + 2 * math . pi , 2 * math . pi )
Average (mean) of angles
Return the average of an input sequence of angles.
Average ( mean ) of angles Return the average of an input sequence of angles .
"""Average (mean) of angles

    Return the average of an input sequence of angles. The result is between
    ``0`` and ``2 * math.pi``.
    If the average is not defined (e.g. ``average_angles([0, math.pi]))``,
    a ``ValueError`` is raised.
    """ # To get outputs from -pi to +pi, delete everything but math.atan2() here.
angles