[AstroPy] append problem in atpy

Tommy Grav tgrav at mac.com
Thu Apr 7 15:47:38 EDT 2011


I am a big fan on atpy and use it extensively in reading IPAC/IRSA tables. However I get this error 
when trying to append two tables with strings that I do not understand. Does anyone know what is happening
and how to get around it

>>> import atpy
>>> t = atpy.Table()
>>> name = ["aa","bb","cc"]
>>> t.add_column("name",name)
>>> k = [1,2,3]
>>> t.add_column("num",k)
>>> t
<Table name='None' rows=3 fields=2>
>>> name = ["aaa","bbb","ccc"]
>>> p = atpy.Table()
>>> p.add_column("name",name)
>>> p.add_column("num",k)
>>> t.append(p)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/basetable.py", line 301, in append
  raise Exception("Columns do not match")
Exception: Columns do not match
>>> nn = t.name.astype("|S3")
>>> t.remove_columns("name")
>>> t.add_column("name",nn)
>>> t.append(p)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/basetable.py", line 302, in append
  self.data = np.hstack((self.data, table.data))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/shape_base.py", line 258, in hstack
  return _nx.concatenate(map(atleast_1d,tup),1)
TypeError: expected a readable buffer object
>>> 

Cheers
 Tommy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20110407/5e01e573/attachment.html>


More information about the AstroPy mailing list