question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Array columns error in Jupyter notebook and lab

See original GitHub issue

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) format

and

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
taldcroftcommented, 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.

1reaction
keflavichcommented, May 4, 2021
$ jupyter --version
jupyter core     : 4.7.0
jupyter-notebook : 6.1.6
qtconsole        : 4.7.7
ipython          : 7.19.0
ipykernel        : 5.1.4
jupyter client   : 6.1.7
jupyter lab      : 2.2.6
nbconvert        : 5.6.1
ipywidgets       : 7.6.1
nbformat         : 5.0.8
traitlets        : 4.3.3

and

$ jupyter --version
jupyter core     : 4.7.1
jupyter-notebook : 6.2.0
qtconsole        : 5.0.2
ipython          : 7.21.0
ipykernel        : 5.1.2
jupyter client   : 6.1.7
jupyter lab      : 1.2.6
nbconvert        : 6.0.7
ipywidgets       : 7.6.3
nbformat         : 5.1.2
traitlets        : 5.0.5

(I tried on both machines)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Couldn't cast array of type string error with cast_column #3668
In OVH cloud during Huggingface Robust-speech-recognition event on a AI training notebook instance using jupyter lab and running jupyter ...
Read more >
Jupyter Notebook: Print 2d array, where each and every row ...
All I just want is a 28 rows and 28 columns for my 28 x 28 2d array. I'm using python on Jupyter...
Read more >
Error with pandas in the Labs Python Integration - KNIME Forum
Hi all, I am trying to run a script using the Labs Python Integration node and I encounter an error that does not...
Read more >
Pandas Series outputs are filled with nulls/errors : DS-2184
When I open the same notebook in browser (without re-running it), the output is shown correctly. When I close DataSpell and open the...
Read more >
NUMPY Arrays Tutorial in Jupyter with examples - YouTube
This Python Numpy arrays tutorial explains how to install, creating arrays, indexing, slicing, reshape, random functions, math and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found