[SciPy-user] Newbie question about boolean condition argument

Giorgio Luciano giorgio.luciano at chimica.unige.it
Wed Dec 6 04:31:14 CST 2006


Sorry for the newbie question, but I'm struggling with the las lines of 
my matlab code for a regression  methods (99% finished) to convert then 
it in numpy/scipy

here they are (matlab code)

s2=find(sig(:,in:c)>0.001&sig(:,in:c)<=0.01)
  if s2~=[]; % for Matlab 7 use if not(isempty(s2));

the first problem is that the command find (and also where) does not 
support a logicla operator as condition :(
because

s2=find(sig(:,in:c)>0.001) works..
but s2=find(sig(:,in:c)>0.001&sig(:,in:c)<=0.01)

give me an error like this

Traceback (most recent call last):
  File "<pyshell#66>", line 1, in -toplevel-
    s3=find(sig1[:,arange(ini,c)]>0.001 and sig1[:,arange(ini,c)]<=0.00 )
ValueError: The truth value of an array with more than one element is 
ambiguous. Use a.any() or a.all()

I've read all the manual about difference in logical and bitwise 
operation... tried with different parenthese, using AND or logical_and, 
& etc. but I didn' manage to do it.

The second question is...(already solve)  does it exist a command like 
(isempty) in scipy/numpy
I used if s2 !=[]  ant it worked perfectly, I was just curious to know 
if the command existed :)

Thanks to all and sorry for the easy question (I've searched in the faq, 
and manual before posting but found nothing)

Giorgio






More information about the SciPy-user mailing list