diff --git a/sympy/sets/fancysets.py b/sympy/sets/fancysets.py index e9f7b434a993..ee2823612906 100644 --- a/sympy/sets/fancysets.py +++ b/sympy/sets/fancysets.py @@ -634,17 +634,35 @@ def __new__(cls, sets, polar=False): # Rectangular Form if polar is False: - obj = ImageSet.__new__(cls, Lambda((x, y), x + I*y), sets) + + if all(_a.is_FiniteSet for _a in sets.args) and (len(sets.args) == 2): + + # ** ProductSet of FiniteSets in the Complex Plane. ** + # For Cases like ComplexPlane({2, 4}*{3}), It + # would return {2 + 3*I, 4 + 3*I} + 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) # Polar Form elif polar is True: new_sets = [] + + # sets is Union of ProductSets if not sets.is_ProductSet: for k in sets.args: new_sets.append(k) + + # sets is ProductSets else: new_sets.append(sets) + # Normalize input theta for k, v in enumerate(new_sets): from sympy.sets import ProductSet new_sets[k] = ProductSet(v.args[0], diff --git a/sympy/sets/tests/test_fancysets.py b/sympy/sets/tests/test_fancysets.py index c776d4029a3f..7c432753b01f 100644 --- a/sympy/sets/tests/test_fancysets.py +++ b/sympy/sets/tests/test_fancysets.py @@ -413,3 +413,13 @@ def test_normalize_theta_set(): # ValueError for non-real sets raises(ValueError, lambda: normalize_theta_set(S.Complexes)) + + +def test_ComplexPlane_FiniteSet(): + x, y, z, a, b, c = symbols('x y z a b c') + + # Issue #9669 + assert ComplexPlane(FiniteSet(a, b, c)*FiniteSet(x, y, z)) == \ + FiniteSet(a + I*x, a + I*y, a + I*z, b + I*x, b + I*y, + b + I*z, c + I*x, c + I*y, c + I*z) + assert ComplexPlane(FiniteSet(2)*FiniteSet(3)) == FiniteSet(2 + 3*I)