From: Chris B. <cb...@sw...> - 2004-02-02 23:55:04
|
Hello. I've graduated from numeric to numarray and been enjoying all the nifty features, but I'm puzzled by the following behaviour when using conditionals in a function like nonzero(): >>> import numarray >>> print numarray.__version__ 0.8 >>> x = numarray.arange(10) >>> numarray.nonzero(x < 5) (array([0, 1, 2, 3, 4]),) So far so good >>> numarray.nonzero(x < 5 and x > 2) (array([3, 4, 5, 6, 7, 8, 9]),) >>> numarray.nonzero((x < 5 and x > 2)) (array([3, 4, 5, 6, 7, 8, 9]),) >>> numarray.nonzero( 2 < x < 5 ) (array([0, 1, 2, 3, 4]),) >>> numarray.nonzero( (x < 5) * (x > 2) ) (array([3, 4]),) So, only this last construction let's me get what I want. Am I doing something wrong or is the use of 'and' and 'or' not implemented for conditionals? Thanks. Chris -- Chris Burns Visiting Assistant Professor Dept. of physics and astronomy, Swarthmore College cb...@sw... http://hven.swarthmore.edu/~burns |