[Numpy-discussion] array without string representation

Stefan van der Walt stefan at sun.ac.za
Mon May 8 10:36:21 EDT 2006


Hi everyone,

While playing around with record arrays, I managed to create
an object that I can't print.  This snippet:

import numpy as N

r = N.zeros(shape=(3,3), dtype=[('x','f4')]).view(N.recarray)
y = r.view('f4')
print "Created y"
print y

produces a traceback:

In [51]: print y
------------------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in ?
  File "/home/stefan//lib/python2.4/site-packages/numpy/core/numeric.py", line 272, in array_str
    return array2string(a, max_line_width, precision, suppress_small, ' ', "", str)
  File "/home/stefan//lib/python2.4/site-packages/numpy/core/arrayprint.py", line 198, in array2string
    separator, prefix)
  File "/home/stefan//lib/python2.4/site-packages/numpy/core/arrayprint.py", line 145, in _array2string
    format_function = a._format
  File "/home/stefan//lib/python2.4/site-packages/numpy/core/records.py", line 176, in __getattribute__
    res = fielddict[attr][:2]
TypeError: unsubscriptable object

Has anyone else seen this sort of thing before?

Regards
Stéfan




More information about the NumPy-Discussion mailing list