[Numpy-discussion] The idiom for supporting matrices and arrays in a function

Alan G Isaac aisaac at american.edu
Thu Mar 2 06:59:00 EST 2006


On Thu, 02 Mar 2006, "Colin J. Williams" apparently wrote: 
> How does asanyyarray() differ from asarray()? 

It leaves alone subclasses of ndarray.  See example below.
Cheers,
Alan Isaac

Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as N
>>> y=N.mat([[1,2],[3,4]])
>>> z1=N.asarray(y)
>>> z2=N.asanyarray(y)
>>> z1
array([[1, 2],
       [3, 4]])
>>> z2
matrix([[1, 2],
       [3, 4]])
>>>






More information about the NumPy-Discussion mailing list