Defining ImageSet union #12011

Open
wants to merge 5 commits into
from

Projects

None yet

3 participants

@Shekharrajak
Member

This PR has some parts of #11188 .
This PR will be useful in simplifying/combining 2 or more ImageSet.

E.g.


In [45]: img1 = ImageSet(Lambda(n, 3*n), S.Integers)
    ...: img2 = ImageSet(Lambda(n, 6*n), S.Integers)
    ...: 

In [46]: Union(img1, img2)
Out[46]: {3⋅n | n ∊ ℤ}

In [47]: img1 = ImageSet(Lambda(n, 2 * n * pi - pi / 3), S.Integers)
    ...: img2 = ImageSet(Lambda(n, 2 * n * pi + 2 * pi / 3), S.Integers)
    ...: img3 = ImageSet(Lambda(n, 2 * n * pi - 2 * pi / 3), S.Integers)
    ...: img4 = ImageSet(Lambda(n, 2 * n * pi + pi / 3), S.Integers)
    ...: img5 = ImageSet(Lambda(n, n * pi - pi / 3), S.Integers)
    ...: img6 = ImageSet(Lambda(n, n * pi - 2 * pi / 3), S.Integers)
    ...: 

In [48]: Union(img1, img2, img3, img4)
Out[48]: 
⎧      2⋅π        ⎫   ⎧      π        ⎫
⎨n⋅π - ─── | n ∊ ℤ⎬ ∪ ⎨n⋅π - ─ | n ∊ ℤ⎬
⎩       3         ⎭   ⎩      3        ⎭

@Shekharrajak
Member

Some testcases are failing since set can produce different order of imageset next time, when we run.

@Shekharrajak
Member
Shekharrajak commented Jan 5, 2017 edited

I hope I have fixed the issue I mentioned here . That time I used FiniteSet . This time I am using list.

Please restart the build (or cross check it in your local system whether it is passing all the time or not (it is done).
I have checked in my system more than 5 times for Python version 3.5, 3.3, 2.7)

Ping @sympy/sympy-solvers @asmeurer @smichr

@asmeurer asmeurer added this to the SymPy 1.1 milestone Jan 5, 2017
sympy/sets/tests/test_sets.py
+ uni1 = ImageSet(Lambda(n, pi * n / 2 + 2 * pi / 3), S.Integers)
+ uni2 = ImageSet(Lambda(n, pi * n / 2 + pi / 3), S.Integers)
+ # One can check the answer using following lines
+ # for i in range(0, 10):
@gxyd
gxyd Jan 9, 2017 Member

using multiline comment here would make that more readable i.e

'''
comments go here
'''
@Shekharrajak
Shekharrajak Jan 9, 2017 Member

Thanks @gxyd , I will do these changes in next commit.

@Shekharrajak
Member

I think, it is good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment