Using Numeric arrays to store different datatypes
Rajarshi Guha
rxg218 at psu.edu
Thu Nov 22 13:23:51 EST 2001
On Thursday 22 November 2001 12:52 in comp.lang.python Phil Austin wrote:
> Rajarshi Guha <rxg218 at psu.edu> writes:
>
>> Hi,
>> Is it possible to store say a list variable in a Numeric array?
>> Or even a class in a Numeric arry?
>>
>
> use Numeric.PyObject, but note there's a bug with
> multidimensional indexing with this type:
>
>>>> testArray=Numeric.zeros(16,Numeric.PyObject)
>>>> testArray[10]=[1,2,3.4]
>>>> testArray
> array([0 , 0 ,
> 0 , 0 ,
> 0 , 0 ,
> 0 , 0 ,
> 0 , 0 ,
> [1, 2, 3.3999999999999999] , 0 ,
> 0 , 0 ,
> 0 , 0 ],'O')
I get the expected 0's. I'm using Active State Python 2.1
>>>> testArray[1,1]=[1,2,3]
If you do testArray[1][1] = [1,2,3] it works fine
Thanks for pointing it out
-------------------------------------------------------------------
Rajarshi Guha | email: rajarshi at presidency.com
152 Davey Laboratory | web : www.rajarshi.outputto.com
Department of Chemistry | ICQ : 123242928
Pennsylvania State University | AIM : LoverOfPanda
-------------------------------------------------------------------
GPG Fingerprint: DCCB 4D1A 5A8B 2F5A B5F6 1F9E CDC4 5574 9017 AF2A
Public Key : http://pgp.mit.edu/
-------------------------------------------------------------------
Got Mole problems? Call Avogadro at 6.02 x 10^23.
More information about the Python-list
mailing list