RunTime error when printing astropy.table.Table row #341

Closed
jwoillez opened this Issue Aug 14, 2012 · 10 comments

Comments

Projects
None yet
4 participants
Member

jwoillez commented Aug 14, 2012

>>> import astropy.table
>>> a = [1, 4, 5]
>>> b = [2.0, 5.0, 8.2]
>>> c = ['x', 'y', 'z']
>>> t = astropy.table.Table([a, b, c], names=('a', 'b', 'c'), meta={'name': 'first table'})
>>> print(t[0])
Traceback (most recent call last):
  File "/Users/jwoillez/Documents/Developments/test/TestTable.py", line 7, in <module>
    print(t[0])
  File "/Users/jwoillez/Documents/Developments/astropy/astropy/table/table.py", line 445, in __repr__
    self.index, self.data, self.dtype)
RuntimeError: maximum recursion depth exceeded while calling a Python object

After further investigation, it looks like an upstream issue with numpy. See: numpy/numpy#385
This could be circumvented by modifying the __repr__ method of astropy.table.Row

def __repr__(self):
    return "<Row {0} of table\n values={1}\n dtype={2}>".format(
        self.index, self.data, self.dtype)

by

def __repr__(self):
    return "<Row {0} of table\n values={1!r}\n dtype={2}>".format(
        self.index, self.data, self.dtype)

Note: self.data is the one with type numpy.void and causing the problem

Owner

taldcroft commented Aug 15, 2012

What platform are you on? I just tried this on my mac (snow leopard) and did not reproduce the issue:

In [1]: >>> import astropy.table
In [2]: >>> a = [1, 4, 5]
In [3]: >>> b = [2.0, 5.0, 8.2]
In [4]: >>> c = ['x', 'y', 'z']
In [5]: >>> t = astropy.table.Table([a, b, c], names=('a', 'b', 'c'), meta={'name': 'first table'})
In [6]: >>> print(t[0])
<Row 0 of table
 values=(1, 2.0, 'x')
 dtype=[('a', '<i8'), ('b', '<f8'), ('c', '|S1')]>
Owner

astrofrog commented Aug 15, 2012

I get the same exception, and am using MacOS 10.7 with Numpy 1.6.2 (I think the Numpy version is what matters)

Member

jwoillez commented Aug 15, 2012

OS X 10.8 with python 2.7.3 and numpy 1.6.2 (as well).

Member

jwoillez commented Aug 15, 2012

By the way, you can exercise the bug in numpy directly, with the following:

>>> import numpy
>>> numpy.__version__
'1.6.2'
>>> format(numpy.void("abc"), "")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: maximum recursion depth exceeded while calling a Python object
Owner

astrofrog commented Aug 15, 2012

I'm surprised this wasn't caught sooner on Jenkins since we test against the latest development version of Numpy. Maybe there was no test that checked for this particular situation?

jwoillez added a commit to jwoillez/astropy that referenced this issue Aug 15, 2012

Added format test to astropy.table.Row.
This should trigger issue #341.

jwoillez added a commit to jwoillez/astropy that referenced this issue Aug 15, 2012

Owner

eteq commented Aug 17, 2012

@taldcroft and @astrofrog - Note that @jwoillez issued a PR to address this (#344) - for some reason github didn't autolink despite it being in the PR title...

Member

jwoillez commented Aug 17, 2012

Of interest as well: numpy/numpy#388
If it (or something equivalent) passes, there is no need for the workaround.

Owner

astrofrog commented Aug 17, 2012

I think there is still a need for a workaround because the bug is in a stable version of Numpy. We should aim for 100% compatibility with all stable Numpy versions since 1.4.1.

taldcroft added a commit that referenced this issue Aug 17, 2012

Merge pull request #344 from jwoillez/issue_341
Issue #341: "RunTime error when printing astropy.table.Table row"
Owner

eteq commented Aug 20, 2012

#344 is merged, so I'll close this. @taldcroft - apparently having "Issue #341" in the merge commit didn't do the trick... maybe it has to be "closes #341"?

@eteq eteq closed this Aug 20, 2012

Owner

astrofrog commented Aug 20, 2012

For the record, you can do:

fixes #xxx
fixed #xxx
fix #xxx
closes #xxx
close #xxx
closed #xxx

(and I think it's case-insensitive).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment