Cannot store Sequences in Numeric arrays of Objects

Stuart I Reynolds S.I.Reynolds at cs.bham.ac.uk
Tue Jun 1 23:42:38 CEST 1999


Hi,

I don't seem to be able to store a whole range of different type in
Numeric's PyObject arrays:

>>> from Numeric import *
>>> a = array( [None,]*9 , PyObject)
>>> b = array( [None,]*9 , PyObject)
>>> a.shape = 3,3
>>> a
array([[None , None , None ],
       [None , None , None ],
       [None , None , None ]],'O')

>>> #Storing ints works fine
>>> a[0,0] = 123
>>> a
array([[123 , None , None ],
       [None , None , None ],
       [None , None , None ]],'O')

>>>#Cannot store an array
>>> a[0,0] = b
Traceback (innermost last):
  File "<stdin>", line 1, in ?
ValueError: array too large for destination

In fact, trying to store any sequence causes the error:

  a[0,0] = []
  a[0,0] = (None, None)
  a[0,0] = UserList()

... whereas storing these works fine:

  a[0,0] = Pickler(file)
  a[0,0] = 'hello'       #Also a sequence?

What's going on?


Cheers,

Stuart




More information about the Python-list mailing list