Repository navigation
Add _repr_latex_ method to table.Table and test for it, fix for #3972 - #11508
Conversation
There was a problem hiding this comment.
Welcome to Astropy 👋 and congratulations on your first pull request! 🎉
A project member will respond to you as soon as possible; in the meantime, please have a look over the Checklist for Contributed Code and make sure you've addressed as many of the questions there as possible.
If you feel that this pull request has not been responded to in a timely manner, please leave a comment mentioning our software support engineer @embray, or send a message directly to the development mailing list. If the issue is urgent or sensitive in nature (e.g., a security vulnerability) please send an e-mail directly to the private e-mail [email protected].
|
Thanks for the PR! Recently, the change log style has been changed, so Also, the code style checks show that there are some errors. You can check there which lines have issues. Essentially, we follow PEP8 conventions to keep the code well organised; this includes removing any trailing white-space, following maximum line length, etc. There are guidelines here that you can follow (you can even check code style before you push code)! Hopefully this solves some of the errors so tests can fully run. |
|
Hey, thanks for your comments. |
|
Thanks! Yes, the failed tests are unrelated. The milestone error is because we still need to set a milestone to this PR. So you don't need to worry about it. I will do a detailed review soon. |
hamogu
left a comment
There was a problem hiding this comment.
Don't be overwhmeled by the number of comments I made! This is pretty close, most of them can be addressed with just a single line of code changed (or removed!). In some cases I've left suggestions. You can accept those in the github website, but then you have to pull from your branch before you continue to work locally. Or you just copy and paste into your code, or write something new - whatever you like!
|
Thank you for your review and the detailed suggestions. |
|
Here are the suggested edits. |
hamogu
left a comment
There was a problem hiding this comment.
Your PR itself is good, but someone an additional file called "exti" in the root directly with > 3000 lines got in there. Those lines look like git commit messages. It;s probably a typo of some sort where you accidentally logged those to a file and then added it to git.
We don't want that file in the history, so you'll have to remove it ("git rm exti"), then squash the commits to make sure it's not merged as part of an intermediate commit. Squashing is explained in the developer docs, please let me know if you need help.
I don't quite understand that text failure. I don't think it's related to your PR, it might go away when you push again. If not, we'll look more closely.
|
OK, almost done. I noted that there is no test for the case when we have a We already have a function to write a LaTeX table with options: So, I'm asking you to make the following change: That simplifies the code, the docs, and the tests (only two cases to test, wich and without meta). In the end, you'll probably have only half the lines that you have now. Don't worry for GSOC, we've seen that you can do the complicated stuff! I'm sorry that this is such a long and winding journey where the things we ask for change with time. I promise this is the last thing. You might wonder why I did not say that in the very beginning. One of the problems with code review is that sometimes I only realize what astropy needs until someone has written a draft to look at and try out. |
|
Hey, thanks for your comment. I have now made changes to the function following your suggestions. |
hamogu
left a comment
There was a problem hiding this comment.
OK, one extra space (marked up a comment). Then, please squash the commits to one (described in the astropy developer docs - let me know if you need help) and once that's done I'll approve and merge.
Essentially done! Thanks!
and a corresponding test for it in test_pprint.py resolves issue astropy#3972 closes astropy#3972
|
Great! |
|
With apologies to all involved, I'd like to recommend reverting this PR for the 4.3 release. Please note @eteq. This has caused some unexpected problems related to Jupyter notebooks for reasons that one never would have guessed. In short, the new rich display method
I think the original use case from @Cadair in #3972 was pretty narrow and that issue has not gotten any other engagement in 6 years. |
|
OK, I agree. Let's revert this. Jupyter is used much more than #3972. I'm glad we got this in sufficiently before the 4.3 freeze, so that there was some real world use beyond our tests to uncover this problem before it made it into a released version. I see several ways of fixing this particular problem (for example the LaTeX table could be limited to the top x rows similar to what is done in the html display) but I agree @Cadair is initial use case is too narrow to warrant that extra complexity though. I do wonder about the notebook and "export to pdf via LaTeX" in nbconvert now. Presumably, for that purpose we do want a latex representation of tables (I don't know which one it pick now, need to check), so let's not throw out this code altogether. No hurry for 4.3, that can be released with this reverted, but we just might have to look at this again after that. |
|
I think this went into the v4.3.x branch, so I think we need @eteq to do the revert. |
Description
This pull request created as part of my application for GSoC 2021, is to add a
_repr_latex_method fortable.Tableobject.@aaryapatil and @hamogu, please have a look.
The
_repr_latex_method can be called usingTable()._repr_latex_().It uses
latex.Latex.write()function fromastropy.io.asciito change the table format to latex. The default LaTeX formatting options defined inlatex.Latexare assumed if nolatexdictargument is passed.See: https://docs.astropy.org/en/latest/api/astropy.io.ascii.Latex.html#astropy.io.ascii.Latex
A new key
latexdictcorresponding toLatex.latexdictionary ofastropy.io.ascii.latexobject is added totable.Table.meta. It contains the LaTeX formatting options for the table used.Fixes #3972