From: Reggie D. <re...@me...> - 2002-06-12 18:55:35
|
This is not, in fact, a bug although I've fallen prey to the same mistake myself. I'm assuming what you really wanted was to use logical_and: Python 2.2.1 (#1, Apr 29 2002, 15:21:53)=20 [GCC 3.0.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from Numeric import * >>> a =3D array((1,1), 'b') >>> b =3D array((1,0), 'b') >>> logical_and(a,b) array([1, 0],'b') >>> logical_and(b,a) array([1, 0],'b') >>>=20 From the python documentation: "The expression x and y first evaluates x; if x is false, its value is returned; otherwise, y is evaluated and the resulting value is returned." So the "and" is just returning its second argument, since both arguments are considered "True" (containing at least 1 "True" element). On Tue, 2002-06-11 at 23:27, Geza Groma wrote: > Using Numeric-21.0.win32-py2.2 I found this: >=20 > Python 2.2.1 (#34, Apr 9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> from Numeric import * > >>> a =3D array((1, 1), 'b') > >>> b =3D array((1, 0), 'b') > >>> a and b > array([1, 0],'b') > >>> b and a > array([1, 1],'b') > >>> >=20 > It looks like a bug, or at least very weird. a&b and b&a work correctly. >=20 > -- > G=E9za Groma > Institute of Biophysics, > Biological Research Center of Hungarian Academy of Sciences > Temesv=E1ri krt.62. > 6726 Szeged > Hungary > phone: +36 62 432 232 > fax: +36 62 433 133 >=20 >=20 >=20 > _______________________________________________________________ >=20 > Sponsored by: > ThinkGeek at http://www.ThinkGeek.com/ > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion Reggie Dugard Merfin, LLC |