Repository navigation
Closed
Description
On astropy version: 4.3.dev1429+ga832159 and 4.3.dev1484+g3f8cf27b8, in a jupyter lab environment, putting a particular table as the only item in a Jupyter Lab cell results in the following traceback and printed out table (MWE):
import numpy as np
from astropy.table import Table
Table([np.ones([10,10]), np.arange(10)])results in both
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/IPython/core/formatters.py in __call__(self, obj)
343 method = get_real_method(obj, self.print_method)
344 if method is not None:
--> 345 return method()
346 return None
347 else:
~/repos/astropy/astropy/table/table.py in _repr_latex_(self)
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
~/repos/astropy/astropy/io/ascii/latex.py in write(self, table)
338 self.header.start_line = None
339 self.data.start_line = None
--> 340 return core.BaseReader.write(self, table=table)
341
342
~/repos/astropy/astropy/io/ascii/core.py in write(self, table)
1474 # Check that table column dimensions are supported by this format class.
1475 # Most formats support only 1-d columns, but some like ECSV support N-d.
-> 1476 self._check_multidim_table(table)
1477
1478 # Now use altered columns
~/repos/astropy/astropy/io/ascii/core.py in _check_multidim_table(self, table)
1282 If any column exceeds the number of allowed dimensions
1283 """
-> 1284 _check_multidim_table(table, self.max_ndim)
1285
1286 def read(self, table):
~/repos/astropy/astropy/io/ascii/core.py in _check_multidim_table(table, max_ndim)
53 nd_names = [col.info.name for col in table.itercols() if len(col.shape) > max_ndim]
54 if nd_names:
---> 55 raise ValueError(f'column(s) with dimension > {max_ndim} '
56 "cannot be be written with this format, try using 'ecsv' "
57 "(Enhanced CSV) format")
ValueError: column(s) with dimension > 1 cannot be be written with this format, try using 'ecsv' (Enhanced CSV) formatand
col0 [10] | col1
-- | --
1.0 .. 1.0 | 0
1.0 .. 1.0 | 1
1.0 .. 1.0 | 2
1.0 .. 1.0 | 3
1.0 .. 1.0 | 4
1.0 .. 1.0 | 5
1.0 .. 1.0 | 6
1.0 .. 1.0 | 7
1.0 .. 1.0 | 8
1.0 .. 1.0 | 9
Activity
saimn commentedon May 4, 2021
Why is it using
_repr_latex_instead of_repr_html_, is that a config option in Jupyter ?pllim commentedon May 4, 2021
What is your
jupyter --version? When it comes to Lab, maybe @mwcraig or @eteq know something.keflavich commentedon May 4, 2021
and
(I tried on both machines)
pllim commentedon May 4, 2021
But it works in a "notebook" right?
keflavich commentedon May 4, 2021
No, the same issue occurs in a pure Notebook too (I hadn't tried that before, but I just tested and verified the result is the same)
pllim commentedon May 4, 2021
Yeah, I tried too. Same results. Works on IPython session though. 🤷
[-]Array columns error[/-][+]Array columns error in Jupyter notebook and lab[/+]saimn commentedon May 4, 2021
Oh indeed, I get the error too on master. Bisect points to b40b22b (cc @taldcroft)
taldcroft commentedon May 5, 2021
The root problem is really using
_repr_latex_instead of_repr_html_. I noticed a problem in the VS code Jupyter extension where it is doing the same thing and displaying the latex for a table. I believe if you take out the check from b40b22b then you'll get a different problem that it shows a latex table not the desired HTML. This seems like an upstream problem where it isn't choosing the cell output type properly.taldcroft commentedon May 5, 2021
I was wondering if
_repr_html_was somehow failing for a multidimensional column now and Jupyter was falling through to_repr_latex_, but seems not since the following works OK:taldcroft commentedon May 5, 2021
So I just don't understand Jupyter notebook. I took out the new check that causes problems and Jupyter runs
_repr_latex_(now successfully) but just throws away that output and moves on to_repr_html_.Anyway, fix coming.