[AstroPy] Problems using tables

Robert Jedrzejewski rij at stsci.edu
Fri Nov 30 11:57:20 EST 2012


  Hi folks,

  I've been playing the the tables module in astropy.  I followed the examples in the documentation (http://astropy.readthedocs.org/en/v0.1/table/index.html) to create a 3 column and 3 row table.  Everything seems to work OK until I try to print a single row of the table t:

>>> t[1]
ERROR: RuntimeError: maximum recursion depth exceeded while calling a Python object [astropy.table.table]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rij/py-lib/astropy/table/table.py", line 445, in __repr__
    self.index, self.data, self.dtype)
RuntimeError: maximum recursion depth exceeded while calling a Python object

  I can assign t[1] to a new variable, creating a Row object, and access all of its methods, but calling __repr__() gives this recursion error.

  Looking at the code, the offending function is

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

  The problem is the second argument; self.data is of type numpy.void and for some reason this doesn't format well using this kind of syntax.  Casting this to np.array type seems to fix this.

  Does this seem like the right way to fix this, or am I missing something obvious here?  (e.g. does the fact that row.data is of type numpy.void mean that something went wrong earlier?)  I don't usually delve too deeply into numpy or astropy because I usually don't have to, it usually works perfectly out of the box :)

  Thanks for any insight,

  Robert J.

  


More information about the AstroPy mailing list