[Numpy-discussion] About asarray (list)

Dag Sverre Seljebotn dagss@student.matnat.uio...
Wed Aug 27 10:00:14 CDT 2008


Manuel Metz wrote:
> Claude Gouedard wrote:
>> Hi ,
>>
>> I'm just surprised by the behaviour of numpy.asarray on  lists.
>>
>> Can someone comment this :
>> =====================
>> a=(1)
>> aa=asarray(a)
>> print  aa.size , aa.shape
>>>> 1   ( )
>> =====================
>>
>> The shape  doesnot reflect the actual size.
> 
> Because a is not a tuple, but an int !!! Try:
> a=(1)
> print a, type(a)
> 

If you want a tuple with one element, try

a = (1,)

-- 
Dag Sverre


More information about the Numpy-discussion mailing list