Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify ComplexPlane({x}*{y}) to FiniteSet(x + I*y) #9671

Merged
merged 3 commits into from Jul 22, 2015

Conversation

aktech
Copy link
Member

@aktech aktech commented Jul 13, 2015

Simplify singleton Element in Complex Plane ComplexPlane({x}*{y}).

fixes #9669

Earlier:

In [6]: ComplexPlane(FiniteSet(x)*FiniteSet(y))
Out[6]: ComplexPlane(Lambda((x, y), x + I*y), {x} x {y})

Now:

In [4]: ComplexPlane(FiniteSet(x)*FiniteSet(y))
Out[4]: {x + I*y}

EDIT TODO

  • Implement this for ProductSet of FiniteSet's of any length.
  • Add Tests

@hargup @flacjacket @jksuom

@aktech aktech added the sets label Jul 13, 2015
obj = ImageSet.__new__(cls, Lambda((x, y), x + I*y), sets)

if (all([_a.is_FiniteSet for _a in sets.args]) and
all([len(_a) == 1 for _a in sets.args])):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the [] here, all() will work fine on a generator, and will make it not have to create a list. You can also combine these with _a.is_FiniteSet and len(_a) == 1 (tho that may not necessarily help performance)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also check that you have exactly 2 args in sets

Signed-off-by: AMiT Kumar <dtu.amit@gmail.com>
@aktech
Copy link
Member Author

aktech commented Jul 21, 2015

@flacjacket @hargup

@jksuom
Copy link
Member

jksuom commented Jul 21, 2015

+1

1 similar comment
@hargup
Copy link
Contributor

hargup commented Jul 22, 2015

+1

hargup added a commit that referenced this pull request Jul 22, 2015
Simplify ComplexPlane({x}*{y}) to FiniteSet(x + I*y)
@hargup hargup merged commit 9e6a4da into sympy:master Jul 22, 2015
@aktech aktech deleted the complex-fs branch July 25, 2015 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ComplexPlane(FiniteSet(x)*FiniteSet(y)) should simplify to {x + I*y}
4 participants