[SciPy-user] matlab isequal equivalent in python or numpy

lorenzo bolla lbolla@gmail....
Wed Jul 11 05:03:06 CDT 2007


can't you use "numpy.all" instead of "all"?


In [786]: x = numpy.arange(10)

In [787]: y = numpy.arange(10)

In [788]: z = numpy.arange(11)

In [789]: all(x==y)
Out[789]: True

In [790]: all(x==z)
------------------------------------
<type 'exceptions.TypeError'>

In [791]: numpy.all(x==y)
Out[791]: True

In [792]: numpy.all(x==z)
Out[792]: False



hth,

lorenzo






On 7/11/07, dmitrey <openopt@ukr.net> wrote:
>
> I need check does array1 equal to array2 or no, lots of times.
> In MATLAB I just used
>
> if isequal(array1, array2) ...
>
> I guess it uses binary code comparison, w/o translating to numbers,
> because isequal works with any types of objects, not only numeric ones
>
> in python I use
>
> if array1.shape==array2.shape and all(array1==array2):...
>
> is it possible to use something more faster and/or better?
> D.
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20070711/75290b9c/attachment.html 


More information about the SciPy-user mailing list