[Numpy-discussion] Possible bug

Colin J. Williams cjw at sympatico.ca
Mon Aug 18 06:37:04 CDT 2003


# ta.py to check Int8, Int16
import numarray as _n
import numarray.numerictypes as _nt
b= _n.arange(4, type= _nt.Int8)
print 'b, b._type:', b, b._type
c= b*1001                                        # Grief here - type not 
updated
print 'c, c._type:', c, c._type    
e= _n.array([1, -2, 3000, 4.6], type= _nt.Int8)  # undocumented feature 
fraction discarded
                                                 # and lowest eight bits 
retained as a signed
                                                 # integer.
print 'e, e._type:', e, e._type
f= _n.array([1, 2, 3, 4.6], type= _nt.Int8) * 9.6
print 'f, f._type:', f, f._type
g= (f.copy()*2000).astype(_nt.Int16)             # undocumented - see e 
above
print 'g, g._type:', g, g._type


--------------------------------------------------------------------
PythonWin 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] 
on win32.
Portions Copyright 1994-2001 Mark Hammond (mhammond at skippinet.com.au) - 
see 'Help/About PythonWin' for further copyright information.
 >>> b, b._type: [0 1 2 3] Int8
c, c._type: [  0 -23 -46 -69] Int8
e, e._type: [  1  -2 -72   4] Int8
f, f._type: [  9.6  19.2  28.8  38.4] Float64
g, g._type: [ 19200 -27136  -7937  11264] Int16

Colin W.





More information about the Numpy-discussion mailing list