[Numpy-discussion] Bitten

Rob W. W. Hooft rob at hooft.net
Fri May 5 16:10:54 CDT 2000


I have to admit that today I have been bitten by NumPy's copy/pointer
and 0-order array inconsistency a bit. Easy enough to fix, but
a nice catch for somebody new to NumPy:

try:

   a=Numeric.array([1,2,3])
   a[0],a[1]=a[1],a[0]
   print a

vs:

   a=Numeric.array([[1,2,3],[4,5,6],[7,8,9]])
   a[0],a[1]=a[1],a[0]
   print a

Regards,

Rob Hooft.

-- 
=====   rob at hooft.net          http://www.xs4all.nl/~hooft/rob/  =====
=====   R&D, Nonius BV, Delft  http://www.nonius.nl/             =====
===== PGPid 0xFA19277D ========================== Use Linux! =========




More information about the Numpy-discussion mailing list