From: Emmanuel V. <vi...@li...> - 2001-07-20 07:18:42
|
Feature, I think. a[1,3] is a rank-0 array, with typecode Int16. There is no other way to handle a Int16 scalar in Python (Int16 is not a python type). This solution allows to correctly propagate the types in array arithmetic, without unwanted upcasts. Emmanuel Chris Barker wrote: > # now change the type > >>> a = a.astype(Int16) > >>> a.shape = (10,) > >>> print type(a[3]) > <type 'int'> > #it's an Int > > >>> a.shape = (2,5) > # now change the shape to rank-2 > > >>> print type(a[1,3]) > <type 'array'> > >>> print a[0,0].typecode() 's' # == Int16 >>> a[0,0].shape () # rank-0 array |