Repository navigation
BUG: Escape LaTeX special characters in the extra text of summaries - #791
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #791 +/- ##
=========================================
Coverage 99.60% 99.60%
=========================================
Files 131 136 +5
Lines 24664 26057 +1393
Branches 1823 1873 +50
=========================================
+ Hits 24566 25954 +1388
+ Misses 39 38 -1
- Partials 59 65 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, @bashtage. Thanks for the great project.
This is the PR I mentioned in #560. I reproduced the problem on current main by exporting the summary of an
IV2SLSwith underscores in the variable names and compiling the result withpdflatex, which fails. A defaultLinearFactorModelsummary fails the same way, with no user variable names involved.Summary.as_latex()escapes the table cells (my\_x) but appends the extra text below the tables unchanged. Underscores in the "Endogenous" and "Instruments" lines, and in the fixed text "See full_summary for complete results" of the asset pricing summaries, make the LaTeX invalid.pdflatexstops with! Missing $ inserted., the failure reported in #560.On main, an
IV2SLSwith variablesmy_x,my_z1,my_z2ends withand with this change
statsmodels'
Summary.as_latex(same in 0.13.1 to 0.15.0) joinsextra_txtwithout escaping it. TheSummaryinlinearmodels.compat.statsmodelsalready overridesas_html, so this addsas_latex. It escapes\ & % $ # _ { } ~ ^in the extra text in onestr.translatepass. Tables,as_text(),as_html()andextra_txtare unchanged, and the output equals statsmodels' when there is nothing to escape.#560 also says the extra text cannot be edited. This does not change that;
s = res.summary; s.extra_txt = Nonealready works.Tests are in
linearmodels/tests/shared/test_base.py. The escaping and end-to-end tests fail on main. Linters are clean and the affected test directories pass. I compiled theas_latex()output of anIV2SLSand aLinearFactorModelsummary withpdflatex: it fails on main and compiles with this change.Fixes #560.