Skip to content

Commit 18a9b32

Browse files
authored
Merge pull request #11711 from astropy/revert-11508-fix-3972
Revert "Add _repr_latex_ method to table.Table and test for it, fix for #3972"
2 parents 642d8ae + 652c955 commit 18a9b32

3 files changed

Lines changed: 0 additions & 66 deletions

File tree

‎astropy/table/table.py‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,31 +1528,6 @@ def _repr_html_(self):
15281528
def __repr__(self):
15291529
return self._base_repr_(html=False, max_width=None)
15301530

1531-
def _repr_latex_(self):
1532-
"""
1533-
Format a Table object into the LaTeX format, and return it as a string.
1534-
1535-
Notes
1536-
-----
1537-
Uses `astropy.io.ascii.latex.Latex.write()` function to change
1538-
the Table format to LaTeX. The default LaTeX formatting options defined
1539-
in ``latex.Latex`` are assumed if the ``table.Table.meta`` dictionary
1540-
doesn't already contain a ``latexdict`` keyword.
1541-
See: `astropy.io.ascii.Latex`
1542-
1543-
A new key ``latexdict`` corresponding to ``Latex.latex`` dictionary of
1544-
``astropy.io.ascii.latex`` object is added to ``table.Table.meta``.
1545-
It contains the LaTeX formatting options for the table used.
1546-
"""
1547-
from astropy.io import ascii
1548-
1549-
latexdict = self.meta.get('latexdict', {})
1550-
lTable = ascii.latex.Latex(latexdict=latexdict)
1551-
lines = lTable.write(table=self)
1552-
self.meta['latexdict'] = lTable.latex
1553-
1554-
return '\n'.join(lines)
1555-
15561531
def __str__(self):
15571532
return '\n'.join(self.pformat())
15581533

‎astropy/table/tests/test_pprint.py‎

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -912,42 +912,3 @@ def test_output_globs(self):
912912
with t.pprint_exclude_names.set('a??'):
913913
out = t.pformat_all()
914914
assert out == exp
915-
916-
917-
def test_repr_latex():
918-
"""
919-
Tests the _repr_latex_ method of astropy.table.Table class.
920-
Output should be a latex formatted table returned as a string.
921-
Test for PR related to issue #3972.
922-
"""
923-
a = [1, 2, 3, 5]
924-
b = np.array([4, 5, 6, 5])
925-
c = ['hello', 'konichiwa', 'namaskar', 'guten morgen']
926-
d = [2, 3, 5, 10] * u.m/u.s**2
927-
t = Table([a, b, c, d], names=('val', 'val1', 'greeting', 'speed'))
928-
929-
lTable1 = [r'\begin{table}',
930-
r'\begin{tabular}{cccc}',
931-
r'val & val1 & greeting & speed \\',
932-
r' & & & $\mathrm{m\,s^{-2}}$ \\',
933-
r'1 & 4 & hello & 2.0 \\',
934-
r'2 & 5 & konichiwa & 3.0 \\',
935-
r'3 & 6 & namaskar & 5.0 \\',
936-
r'5 & 5 & guten morgen & 10.0 \\',
937-
r'\end{tabular}',
938-
r'\end{table}']
939-
assert t._repr_latex_().splitlines() == lTable1
940-
941-
lTable2 = [r'\begin{table}',
942-
r'\caption{this is a table}',
943-
r'\begin{tabular}{cccc}',
944-
r'val & val1 & greeting & speed \\',
945-
r' & & & $\mathrm{m\,s^{-2}}$ \\',
946-
r'1 & 4 & hello & 2.0 \\',
947-
r'2 & 5 & konichiwa & 3.0 \\',
948-
r'3 & 6 & namaskar & 5.0 \\',
949-
r'5 & 5 & guten morgen & 10.0 \\',
950-
r'\end{tabular}',
951-
r'\end{table}']
952-
t.meta['latexdict'] = {'caption':'this is a table'}
953-
assert t._repr_latex_().splitlines() == lTable2

‎docs/changes/table/11508.feature.rst‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)