[SciPy-user] buffered data not permissible
Alan G Isaac
aisaac at american.edu
Sun Dec 11 08:22:37 CST 2005
Here's a simple illustration of a problem that surprised me:
one can create a working array with zip but not with izip.
It appears intentional.
Can someone tell me why?
Two things looking like a small bug. If you make an array out of
an itertools.izip object:
- the result is not iterable
- it's representation is that it is an itertools.izip object
(which seems to be false)
Thank you,
Alan Isaac
>>> scipy.base.__version__
'0.4.2.1252'
>>> x=scipy.array(zip(xrange(5),itertools.cycle([1])))
>>> x
array([[0, 1],
[1, 1],
[2, 1],
[3, 1],
[4, 1]])
>>> x=scipy.array(itertools.izip(xrange(5),itertools.cycle([1])))
>>> x
<itertools.izip object at 0x02005E18>
>>> type(x)
<type 'object_arrtype'>
>>> list(x)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: iteration over non-sequence
>>> x=scipy.mat(zip(xrange(5),itertools.cycle([1])))
>>> x=scipy.mat(itertools.izip(xrange(5),itertools.cycle([1])))
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python24\lib\site-packages\scipy\base\matrix.py", line 87, in __new__
swap=(not arr.flags['NOTSWAPPED']))
TypeError: cannot construct an object array from buffer data.
>>>
More information about the SciPy-user
mailing list