

def normalize_theta_set(theta):
    '\n    Normalize a Real Set `theta` in the Interval [0, 2*pi). It returns\n    a normalized value of theta in the Set. For Interval, a maximum of\n    one cycle [0, 2*pi], is returned i.e. for theta equal to [0, 10*pi],\n    returned normalized value would be [0, 2*pi). As of now intervals\n    with end points as non-multiples of `pi` is not supported.\n\n    Raises\n    ======\n\n    NotImplementedError\n        The algorithms for Normalizing theta Set are not yet\n        implemented.\n    ValueError\n        The input is not valid, i.e. the input is not a real set.\n    RuntimeError\n        It is a bug, please report to the github issue tracker.\n\n    Examples\n    ========\n\n    >>> from sympy.sets.fancysets import normalize_theta_set\n    >>> from sympy import Interval, FiniteSet, pi\n    >>> normalize_theta_set(Interval(9*pi/2, 5*pi))\n    [pi/2, pi]\n    >>> normalize_theta_set(Interval(-3*pi/2, pi/2))\n    [0, 2*pi)\n    >>> normalize_theta_set(Interval(-pi/2, pi/2))\n    [0, pi/2] U [3*pi/2, 2*pi)\n    >>> normalize_theta_set(Interval(-4*pi, 3*pi))\n    [0, 2*pi)\n    >>> normalize_theta_set(Interval(-3*pi/2, -pi/2))\n    [pi/2, 3*pi/2]\n    >>> normalize_theta_set(FiniteSet(0, pi, 3*pi))\n    {0, pi}\n\n    '
    from sympy.functions.elementary.trigonometric import _pi_coeff as coeff
    if theta.is_Interval:
        interval_len = theta.measure
        if (interval_len >= (2 * S.Pi)):
            if ((interval_len == (2 * S.Pi)) and theta.left_open and theta.right_open):
                k = coeff(theta.start)
                return Union(Interval(0, (k * S.Pi), False, True), Interval((k * S.Pi), (2 * S.Pi), True, True))
            return Interval(0, (2 * S.Pi), False, True)
        (k_start, k_end) = (coeff(theta.start), coeff(theta.end))
        if ((k_start is None) or (k_end is None)):
            raise NotImplementedError('Normalizing theta without pi as coefficient is not yet implemented')
        new_start = (k_start * S.Pi)
        new_end = (k_end * S.Pi)
        if (new_start > new_end):
            return Union(Interval(S.Zero, new_end, False, theta.right_open), Interval(new_start, (2 * S.Pi), theta.left_open, True))
        else:
            return Interval(new_start, new_end, theta.left_open, theta.right_open)
    elif theta.is_FiniteSet:
        new_theta = []
        for element in theta:
            k = coeff(element)
            if (k is None):
                raise NotImplementedError('Normalizing theta without pi as coefficient, is not Implemented.')
            else:
                new_theta.append((k * S.Pi))
        return FiniteSet(*new_theta)
    elif theta.is_Union:
        return Union(*[normalize_theta_set(interval) for interval in theta.args])
    elif theta.is_subset(S.Reals):
        raise NotImplementedError(('Normalizing theta when, it is of type %s is not implemented' % type(theta)))
    else:
        raise ValueError((' %s is not a real set' % theta))

dataset/ETHPy150Open sympy/sympy/sympy/sets/fancysets.py normalize_theta_set/original