Skip to content

Conversation

oscargus
Copy link
Contributor

@oscargus oscargus commented Aug 23, 2021

References to other Issues or PRs

Closes #21823

Brief description of what is fixed or changed

FiniteSet is now printed with {}, see #21823.

Other comments

Release Notes

  • printing
    • FiniteSet now prints as {...} instead of FiniteSet(...) in the string printer, unless it contains a FiniteSet.

@sympy-bot
Copy link

sympy-bot commented Aug 23, 2021

Hi, I am the SymPy bot (v161). 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
    • FiniteSet now prints as {...} instead of FiniteSet(...) in the string printer, unless it contains a FiniteSet. (#21931 by @oscargus)

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

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://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->

Closes #21823

#### Brief description of what is fixed or changed
`FiniteSet` is now printed with `{}`, see #21823.

#### Other comments


#### Release Notes

<!-- Write the release notes for this release below between the BEGIN and END
statements. The basic format is a bulleted list with the name of the subpackage
and the release note for this PR. For example:

* solvers
  * Added a new solver for logarithmic equations.

* functions
  * Fixed a bug with log of integers.

or if no release note(s) should be included use:

NO ENTRY

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
     * `FiniteSet` now prints as `{...}` instead of `FiniteSet(...)` in the string printer, unless it contains a `FiniteSet`.   
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@smichr
Copy link
Member

smichr commented Aug 24, 2021

This won't work for a FiniteSet of FiniteSets: you won't be able to copy and paste the result since the internals sets will be interpreted as python sets and they are unhashable. So either the parser would have to recognize that or else the printer needs to not print its args as sets.

@oscargus
Copy link
Contributor Author

Thanks @smichr. I have an ongoing fix for the loads of failures, but stopped after a while to get some feedback before spending time on fixing them all.

I guess that printing the outer set as FiniteSet and the inner sets as {} should work? That is probably the easiest thing to program as well. if any(arg.has(FiniteSet) for arg in args): sort of.

@github-actions
Copy link

Benchmark results from GitHub Actions

Lower numbers are good, higher numbers are bad. A ratio less than 1
means a speed up and greater than 1 means a slowdown. Green lines
beginning with + are slowdowns (the PR is slower then master or
master is slower than the previous release). Red lines beginning
with - are speedups.

Significantly changed benchmark results (PR vs master)

Significantly changed benchmark results (master vs previous release)

       before           after         ratio
     [ed9a550f]       [63b86653]
     <sympy-1.8^0>                 
-      1.17±0.01s          162±3ms     0.14  dsolve.TimeDsolve01.time_dsolve
-      8.88±0.04s       4.61±0.03s     0.52  integrate.TimeIntegrationRisch02.time_doit_risch(100)
-        75.6±3μs       28.3±0.8μs     0.37  matrices.TimeDiagonalEigenvals.time_eigenvals
-        89.8±4μs         58.0±5μs     0.65  matrices.TimeMatrixGetItem.time_ImmutableSparseMatrix_getitem
-        86.2±1μs       55.3±0.8μs     0.64  matrices.TimeMatrixGetItem.time_MutableSparseMatrix_getitem
+      6.15±0.2ms       9.48±0.6ms     1.54  physics.mechanics.kane.KanesMethodMassSpringDamper.time_kanesmethod_mass_spring_damper
+        91.5±1μs         162±40μs     1.77  solve.TimeMatrixArithmetic.time_dense_add(10, 5)
+     11.7±0.09μs       20.9±0.9μs     1.78  solve.TimeMatrixArithmetic.time_dense_add(3, 0)
+      14.1±0.2μs         40.6±2μs     2.88  solve.TimeMatrixArithmetic.time_dense_add(3, 5)
+      17.6±0.1μs         27.5±2μs     1.56  solve.TimeMatrixArithmetic.time_dense_add(4, 0)
+      37.9±0.2μs       67.2±0.6μs     1.77  solve.TimeMatrixArithmetic.time_dense_add(6, 5)
-     1.24±0.02ms          244±9μs     0.20  solve.TimeMatrixArithmetic.time_dense_multiply(10, 0)
-      48.8±0.8μs       25.7±0.8μs     0.53  solve.TimeMatrixArithmetic.time_dense_multiply(3, 0)
+        76.8±2μs         139±10μs     1.81  solve.TimeMatrixArithmetic.time_dense_multiply(3, 5)
-       100±0.9μs         35.2±3μs     0.35  solve.TimeMatrixArithmetic.time_dense_multiply(4, 0)
-         298±6μs        86.6±10μs     0.29  solve.TimeMatrixArithmetic.time_dense_multiply(6, 0)
-        92.6±2μs         46.2±4μs     0.50  solve.TimeMatrixOperations.time_det(3, 0)
-         182±7μs         115±20μs     0.63  solve.TimeMatrixOperations.time_det(3, 2)
-      91.3±0.7μs         42.2±1μs     0.46  solve.TimeMatrixOperations.time_det_bareiss(3, 0)
-         177±1μs          104±2μs     0.59  solve.TimeMatrixOperations.time_det_bareiss(3, 2)
-         169±3μs       94.0±0.4μs     0.56  solve.TimeMatrixOperations.time_det_bareiss(3, 5)
-        91.4±1μs         42.7±1μs     0.47  solve.TimeMatrixOperations.time_det_berkowitz(3, 0)
-        203±20μs          128±7μs     0.63  solve.TimeMatrixOperations.time_det_berkowitz(3, 2)
+        783±70μs       1.50±0.1ms     1.91  solve.TimeMatrixOperations.time_det_berkowitz(4, 0)
+        944±10μs       2.14±0.3ms     2.26  solve.TimeMatrixOperations.time_det_berkowitz(4, 2)
+         453±9μs         733±20μs     1.62  solve.TimeMatrixOperations.time_rank(4, 0)
+        875±10μs       1.38±0.3ms     1.58  solve.TimeMatrixSolve.time_solve_sym('LU')
-      5.97±0.5ms       3.35±0.3ms     0.56  solve.TimeRationalSystem.time_linsolve(10)
-      3.39±0.5ms      2.22±0.01ms     0.65  solve.TimeSparseSystem.time_linsolve_eqs(30)

Full benchmark results can be found as artifacts in GitHub Actions
(click on checks at the top of the PR).

@oscargus
Copy link
Contributor Author

Updated version with fixed tests (and added tests).

@smichr
Copy link
Member

smichr commented Aug 25, 2021

I guess that printing the outer set as FiniteSet and the inner sets as {} should work?

Oh, that's a great idea.

@smichr
Copy link
Member

smichr commented Aug 25, 2021

This gets my vote for beauty award this round! Thanks,

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.

nicer printing of Permutation (and others)
3 participants