When I run it in Python 2.7, thetaTest is an array, not a list as in Fons'
example, so the comparison works as expected and produces a boolean array

  >>> array([.1, .2, .3, .4]) > .25
array([False, False,  True,  True], dtype=bool)

and boolean types behave like the constants 0 and 1 under multiplication

 >>> array([1,2,3,4]) * (array([.1, .2, .3, .4]) > .25)
array([0, 0, 3, 4])

I don't know much about Python 3.

Aaron


On Mon, Mar 17, 2014 at 7:07 PM, Marc Lavallée <m...@hacklava.net> wrote:

>
> Fons, here's my little code review:
> The "bug" is harmless, because the WbinVec variable is used only if
> WBIN is considered True, and WBIN is actually a constant set to 0.
>
> --
> Marc
>
>
> Le Tue, 18 Mar 2014 01:01:25 +0000,
> Fons Adriaensen <f...@linuxaudio.org> a écrit :
>
> > On Mon, Mar 17, 2014 at 05:06:32PM -0700, Aaron Heller wrote:
> > >  On Mon, Mar 17, 2014 at 1:09 PM, Fons Adriaensen
> > > <f...@linuxaudio.org>wrote:
> > >
> > > > On Mon, Mar 17, 2014 at 06:05:11PM +0100, /dav/random wrote:
> > > >
> > > > > The project is called IDHOA and the code is hosted here [1]
> > > > > under GPL .
> > > >
> > > > (after automatic conversion to python3)
> > > >
> > > > Traceback (most recent call last):
> > > >   File "./main.py", line 32, in <module>
> > > >     from constants import *
> > > >   File "/data/build/idhoa/constants.py", line 106, in <module>
> > > >     WbinVec = fu.Wbinary()
> > > >   File "/data/build/idhoa/functions.py", line 525, in Wbinary
> > > >     return  thetaTest > thetaThreshold
> > > > TypeError: unorderable types: list() > float()
> > > >
> > >
> > >
> > > It runs fine in Python 2.7 with NLOpt 2.4.1
> > >
> > > It took about 370 seconds to solve the example speaker array at
> > > 3rd-order. From a quick look at the usual performance metrics,  the
> > > resulting coefficients look pretty good for a challenging array.
> >
> > It turns out that Python 2 allows to compare a list of floats
> > to a float. But the result is probably not what the authors
> > assumed it to be:
> >
> > Python 2.7.6 (default, Nov 26 2013, 12:52:49)
> > [GCC 4.8.2] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> A = [0.1, 0.2, 0.3]
> > >>> A > 1000
> > True
> > >>> A > -1000
> > True
> > >>> A < 1000
> > False
> > >>> A < -1000
> > False
> > >>>
> >
> > In other words, the compare that Python 3 refuses will always
> > return True in Python 2. I suspect this is a bug.
> >
> > Ciao,
>
> _______________________________________________
> Sursound mailing list
> Sursound@music.vt.edu
> https://mail.music.vt.edu/mailman/listinfo/sursound
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<https://mail.music.vt.edu/mailman/private/sursound/attachments/20140317/9ab9562c/attachment.html>
_______________________________________________
Sursound mailing list
Sursound@music.vt.edu
https://mail.music.vt.edu/mailman/listinfo/sursound

Reply via email to