[Numpy-discussion] Problem with str.format() and np.recarray

Tom Aldcroft aldcroft at head.cfa.harvard.edu
Tue May 22 09:39:41 EDT 2012


I came across this problem which appears to be new in numpy 1.6.2 (vs. 1.6.1):

In [17]: a = np.array([(1, )], dtype=[('a', 'i4')])

In [18]: ra = a.view(np.recarray)

In [19]: '{}'.format(ra[0])
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/data/baffin/tom/git/eng_archive/<ipython-input-19-cbdd26e3ea78> in <module>()
----> 1 '{}'.format(ra[0])

RuntimeError: maximum recursion depth exceeded while calling a Python object

In [20]: str(ra[0])
Out[20]: '(1,)'

In [21]: ra[0]
Out[21]: (1,)

There are obvious workarounds but it seems something is not right.
I'm running Python 2.7 on linux x86_64.

Cheers,
Tom



More information about the NumPy-Discussion mailing list