

def __new__(cls, sets, polar=False):
    from sympy import sin, cos
    (x, y, r, theta) = symbols('x, y, r, theta', cls=Dummy)
    I = S.ImaginaryUnit
    polar = sympify(polar)
    if (polar == False):
        if (all((_a.is_FiniteSet for _a in sets.args)) and (len(sets.args) == 2)):
            complex_num = []
            for x in sets.args[0]:
                for y in sets.args[1]:
                    complex_num.append((x + (I * y)))
            obj = FiniteSet(*complex_num)
        else:
            obj = ImageSet.__new__(cls, Lambda((x, y), (x + (I * y))), sets)
        obj._variables = (x, y)
        obj._expr = (x + (I * y))
    elif (polar == True):
        new_sets = []
        if (not sets.is_ProductSet):
            for k in sets.args:
                new_sets.append(k)
        else:
            new_sets.append(sets)
        for (k, v) in enumerate(new_sets):
            from sympy.sets import ProductSet
            new_sets[k] = ProductSet(v.args[0], normalize_theta_set(v.args[1]))
        sets = Union(*new_sets)
        obj = ImageSet.__new__(cls, Lambda((r, theta), (r * (cos(theta) + (I * sin(theta))))), sets)
        obj._variables = (r, theta)
        obj._expr = (r * (cos(theta) + (I * sin(theta))))
    else:
        raise ValueError('polar should be either True or False')
    obj._sets = sets
    obj._polar = polar
    return obj

dataset/ETHPy150Open sympy/sympy/sympy/sets/fancysets.py ComplexRegion.__new__/original