Skip to content

Conversation

@sylee957
Copy link
Member

References to other Issues or PRs

Brief description of what is fixed or changed

Test code

from sympy import *
from sympy.abc import a, b, c, d, e, f, g, h
from sympy.printing.precedence import PRECEDENCE

from IPython.display import display

A = FiniteSet(a)
B = FiniteSet(b)
C = FiniteSet(c)
D = FiniteSet(d)

U1 = Union(A, B, evaluate=False)
U2 = Union(C, D, evaluate=False)
I1 = Intersection(A, B, evaluate=False)
I2 = Intersection(C, D, evaluate=False)
C1 = Complement(A, B, evaluate=False)
C2 = Complement(C, D, evaluate=False)
D1 = SymmetricDifference(A, B, evaluate=False)
D2 = SymmetricDifference(C, D, evaluate=False)
# XXX ProductSet does not support evaluate keyword
P1 = ProductSet(A, B)
P2 = ProductSet(C, D)

display(Intersection(A, U2, evaluate=False))
display(Intersection(U1, U2, evaluate=False))
display(Intersection(C1, C2, evaluate=False))
display(Intersection(D1, D2, evaluate=False))
display(Intersection(P1, P2, evaluate=False))

display(Union(A, I2, evaluate=False))
display(Union(I1, I2, evaluate=False))
display(Union(C1, C2, evaluate=False))
display(Union(D1, D2, evaluate=False))
display(Union(P1, P2, evaluate=False))

display(Complement(A, C2, evaluate=False))
display(Complement(U1, U2, evaluate=False))
display(Complement(I1, I2, evaluate=False))
display(Complement(D1, D2, evaluate=False))
display(Complement(P1, P2, evaluate=False))

display(SymmetricDifference(A, D2, evaluate=False))
display(SymmetricDifference(U1, U2, evaluate=False))
display(SymmetricDifference(I1, I2, evaluate=False))
display(SymmetricDifference(C1, C2, evaluate=False))
display(SymmetricDifference(P1, P2, evaluate=False))

display(ProductSet(A, P2))
display(ProductSet(U1, U2))
display(ProductSet(I1, I2))
display(ProductSet(C1, C2))
display(ProductSet(D1, D2))

The result was like
image
But I don't think that different set operators are compatible such way
image

I've also switched the precedence_traditional to use dictionary mapping, which may hopefully clean up some code.

Other comments

I've not fixed mathml here yet, but if there are same problems, it should be fixed too.

Release Notes

  • printing
    • Fixed missing parenthesis for set operators Union, Intersection, Complement, SymmetricDifference, ProductSet

@sympy-bot
Copy link

sympy-bot commented Aug 29, 2019

Hi, I am the SymPy bot (v147). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • printing
    • Fixed missing parenthesis for set operators Union, Intersection, Complement, SymmetricDifference, ProductSet (#17538 by @sylee957)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.5.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234". See
https://github.com/blog/1506-closing-issues-via-pull-requests . Please also
write a comment on that issue linking back to this pull request once it is
open. -->


#### Brief description of what is fixed or changed


<details><summary>Test code</summary>
<p>

```python
from sympy import *
from sympy.abc import a, b, c, d, e, f, g, h
from sympy.printing.precedence import PRECEDENCE

from IPython.display import display

A = FiniteSet(a)
B = FiniteSet(b)
C = FiniteSet(c)
D = FiniteSet(d)

U1 = Union(A, B, evaluate=False)
U2 = Union(C, D, evaluate=False)
I1 = Intersection(A, B, evaluate=False)
I2 = Intersection(C, D, evaluate=False)
C1 = Complement(A, B, evaluate=False)
C2 = Complement(C, D, evaluate=False)
D1 = SymmetricDifference(A, B, evaluate=False)
D2 = SymmetricDifference(C, D, evaluate=False)
# XXX ProductSet does not support evaluate keyword
P1 = ProductSet(A, B)
P2 = ProductSet(C, D)

display(Intersection(A, U2, evaluate=False))
display(Intersection(U1, U2, evaluate=False))
display(Intersection(C1, C2, evaluate=False))
display(Intersection(D1, D2, evaluate=False))
display(Intersection(P1, P2, evaluate=False))

display(Union(A, I2, evaluate=False))
display(Union(I1, I2, evaluate=False))
display(Union(C1, C2, evaluate=False))
display(Union(D1, D2, evaluate=False))
display(Union(P1, P2, evaluate=False))

display(Complement(A, C2, evaluate=False))
display(Complement(U1, U2, evaluate=False))
display(Complement(I1, I2, evaluate=False))
display(Complement(D1, D2, evaluate=False))
display(Complement(P1, P2, evaluate=False))

display(SymmetricDifference(A, D2, evaluate=False))
display(SymmetricDifference(U1, U2, evaluate=False))
display(SymmetricDifference(I1, I2, evaluate=False))
display(SymmetricDifference(C1, C2, evaluate=False))
display(SymmetricDifference(P1, P2, evaluate=False))

display(ProductSet(A, P2))
display(ProductSet(U1, U2))
display(ProductSet(I1, I2))
display(ProductSet(C1, C2))
display(ProductSet(D1, D2))
```

</p>
</details>

The result was like
![image](https://user-images.githubusercontent.com/34944973/63901358-2db38180-ca3f-11e9-919a-aadb6e296abc.png)
But I don't think that different set operators are compatible such way
![image](https://user-images.githubusercontent.com/34944973/63901411-66535b00-ca3f-11e9-9333-c04b0b635490.png)

I've also switched the `precedence_traditional` to use dictionary mapping, which may hopefully clean up some code.

#### Other comments

I've not fixed mathml here yet, but if there are same problems, it should be fixed too.

#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
- printing
  - Fixed missing parenthesis for set operators `Union`, `Intersection`, `Complement`, `SymmetricDifference`, `ProductSet`
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@codecov
Copy link

codecov bot commented Aug 29, 2019

Codecov Report

Merging #17538 into master will decrease coverage by 12.704%.
The diff coverage is 59.523%.

@@              Coverage Diff               @@
##            master    #17538        +/-   ##
==============================================
- Coverage   74.715%   62.011%   -12.705%     
==============================================
  Files          633       633                
  Lines       164499    164525        +26     
  Branches     38623     38621         -2     
==============================================
- Hits        122906    102024     -20882     
- Misses       36201     56709     +20508     
- Partials      5392      5792       +400

@oscargus
Copy link
Contributor

Looks good! (Raw strings are so much easier to read when it comes to LaTeX output, but not worth changing.)

@oscargus oscargus merged commit 215b9ee into sympy:master Aug 29, 2019
@sylee957 sylee957 deleted the fix_latex_set_op branch August 29, 2019 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants