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

Refactored LaTeX generation in preview #22734

Merged
merged 4 commits into from
Jun 19, 2022

Conversation

oscargus
Copy link
Contributor

References to other Issues or PRs

Brief description of what is fixed or changed

Refactored the interactive LaTeX generation a bit so that the LaTeX preamble etc are defined in a single place.

Other comments

As an added bonus one can specify fontsize as an int, but I do not think that warrants a release note. Although it is mentioned in the documentation.

Release Notes

NO ENTRY

@sympy-bot
Copy link

sympy-bot commented Dec 21, 2021

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

  • No release notes entry will be added for this pull request.
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. -->


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

Refactored the interactive LaTeX generation a bit so that the LaTeX preamble etc are defined in a single place.

#### Other comments

As an added bonus one can specify fontsize as an int, but I do not think that warrants a release note. Although it is mentioned in the documentation.

#### 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 -->
NO ENTRY
<!-- END RELEASE NOTES -->

@oscargus oscargus force-pushed the betterinteractivelatex branch 3 times, most recently from 24a1ed8 to 6cd24d9 Compare December 21, 2021 13:44
@github-actions
Copy link

github-actions bot commented Dec 21, 2021

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
     [77f1d79c]       [eb9caeb0]
     <sympy-1.10.1^0>                 
+        97.9±1ms        177±0.6ms     1.81  sum.TimeSum.time_doit

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

@oscarbenjamin
Copy link
Contributor

I think this looks good although I'm not really sure how to test it. I don't think I've seen preview work on OSX.

@oscargus
Copy link
Contributor Author

All the LaTeX generation (like in IPython and Spyder) goes through preview and it is only the LaTeX-file generation that has been refactored (and slightly changed).

(I have problems testing the other aspects of preview as well.)

@asmeurer
Copy link
Member

preview() works just fine on Mac if you configure it to save to a file. The only issue is with the default Pyglet viewer. IMO pyglet shouldn't be the default (for preview or plotting).

Ideally viewer='open' (meaning use the open command, which would open it in Preview.app) ought to work and be the default on Mac, but it doesn't for me (it opens Preview but no image is opened).

See also #13621 and #15680

@oscargus
Copy link
Contributor Author

I was thinking about adding a 'system' viewer, but that requires platform-specific code and when I didn't get it to work on Windows (because the default viewers returns after starting causing the temporary file to be deleted before it is loaded in the viewer...), I didn't spend more time on it...

@asmeurer
Copy link
Member

Doing NotImplementedError on Windows for now would be fine. I will say my experience on Windows in general is that you shouldn't delete files that are open in programs like you would in Unix, so you'd have to find a way to only delete the file after the program closes. Perhaps Windows has some API for this?

@oscargus
Copy link
Contributor Author

Except from that the feature request from @asmeurer about an ability to open a file in the system viewer is not implemented, this PR does what it originally was supposed to do: generate the LaTeX-file in a single place and use the same LaTeX-file for different cases. I think it may just as well go into 1.11.

@oscargus oscargus added this to the SymPy 1.11 milestone Jun 18, 2022
@oscarbenjamin oscarbenjamin reopened this Jun 18, 2022
@oscarbenjamin
Copy link
Contributor

Not sure what the circleci error is. I guess that's because this PR predates using circleci.

@asmeurer does the circleci build use the PR branch or does it use the branch resulting from merging the PR into master (like most other things in CI do)?

@oscarbenjamin
Copy link
Contributor

@oscargus I haven't looked through this in detail but it looks fine. Feel free to merge if you're happy with it.

sympy/printing/preview.py Outdated Show resolved Hide resolved
@oscargus oscargus force-pushed the betterinteractivelatex branch 2 times, most recently from 029b293 to 7849b93 Compare June 19, 2022 09:10
@oscargus
Copy link
Contributor Author

I changed the name of preamble_lines to extra_preamble to reduce the confusion if it is actually lines (as in a tuple or list) or just a string.

@oscargus
Copy link
Contributor Author

I rebased and then the CircleCI stuff was OK (I guess this was pretty old).

@oscargus oscargus enabled auto-merge June 19, 2022 09:13
@oscargus oscargus merged commit cdd8219 into sympy:master Jun 19, 2022
@oscarbenjamin
Copy link
Contributor

I think something funny happened with the rebase because it's showing extra commits that were already on master.

@oscargus
Copy link
Contributor Author

Ahh! Sorry about that! And automerge on top of that...

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

Successfully merging this pull request may close these issues.

None yet

5 participants