Hello All:
I have a question of the logical 'and' as it relates to ndarray s and whether what I'm seeing is a bug or not. I just upgraded to the latest scipy (as shown below) on a WindowsXP system and found a piece of code that worked previously (essentially line 5 below) but now gives an error.
After a little digging, I found that using an '==' would be equivalent to the 'and' I had wanted to use. However, just curious if the syntax in line 5 should have worked as well.
[1]>>> import scipy
[2]>>> scipy.__scipy_version__
'0.4.3'
[3]>>> scipy.__core_version__
'0.6.1'
[4]>>> a=scipy.array([1,2,3,4,5,6],'d')
[5]>>> idx = scipy.where( (a>2) and (a<5), 1, 0 )
Traceback (most recent call last):
File "<pyshell#80>", line 1, in -toplevel-
idx = scipy.where( (a>2) and (a<5), 1, 0 )
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
[6]>>> idx = scipy.where( (a>2)==(a<5), 1, 0 )
[7]>>> idx
array([0, 0, 1, 1, 0, 0])
Thanks in advance,
Michael