correct Numeric behavior? 
Author Message
 correct Numeric behavior?

The following seems counterintuitive:

Quote:
>>> import Numeric
>>> a = Numeric.array([0])
>>> a
array([0])
>>> not a
1
>>> b = Numeric.array([1])
>>> not b

0

That is, a rank-1 array if length 1 tests false if it's value is 0,
but true otherwise.  This is not the case with the array module:

Quote:
>>> import array
>>> x = array.array("i", [0])
>>> x
array('i', [0])
>>> not x

0

Is this the intended behavior of Numeric, or is this a bug?



Fri, 08 Oct 2004 08:16:15 GMT  
 correct Numeric behavior?

Quote:
> The following seems counterintuitive:

> >>> import Numeric
> >>> a = Numeric.array([0])
> >>> a
> array([0])
> >>> not a
> 1
> >>> b = Numeric.array([1])
> >>> not b
> 0

Oh GREAT!  Another way to test for False!

;-)

--

Emile van Sebille

---------



Fri, 08 Oct 2004 11:13:13 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. correct behavior

2. Is this behavior correct?

3. the correct behavior

4. Correct behavior for file-write-date?

5. Correct behavior for failure during __init__()

6. Correct behavior for failure during __init__()

7. Tk4.0b: please correct the binding behavior

8. numeric digits & funny behavior

9. Strange Numeric behavior for failed assignment

10. moving a alpha numeric field to a numeric field

11. archive announcement, corrected

12. Do you prove your APL programs correct?

 

 
Powered by phpBB® Forum Software