Changes to bools under Numexpr

Ivan Vilata i Balaguer ivilata at carabos.com
Thu Oct 26 07:57:37 EDT 2006


Hi all.  The attached diff makes some changes to Numexpr support for
booleans.  The changes and their rationale are below.

1. New ``True`` and ``False`` boolean constants.  This is so that 1 and
   0 are always proper integer constants.  It is also for completeness,
   but I don't envision any usage for them that couldn't be expressed
   without the constants.

2. The only comparisons supported with booleans are ``==`` and ``!=``,
   so that you can compare boolean variables.  Just as NumPy supports
   complex order comparisons and Numexpr doesn't, so goes for bools.
   Being relatively new, I think there is no need to keep
   integer-boolean compatibility in Numexpr.  What was the meaning of
   ``True > False`` or ``2 > True`` anyway?

3. This is also why casting booleans to normal numbers is not allowed,
   so ``prod()`` and ``sum()`` on booleans aren't either.  What is the
   meaning of boolean addition anyway?

To make it short, this patch is kind of a strengthening of boolean
values.  I expect some people to disagree with the changes, and that's
why I would really like to hear your opinions on it.

Regards,

::

	Ivan Vilata i Balaguer   >qo<   http://www.carabos.com/
	       Cárabos Coop. V.  V  V   Enjoy Data
	                          ""
-------------- next part --------------
A non-text attachment was scrubbed...
Name: numexpr-bool2.diff
Type: text/x-patch
Size: 8581 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20061026/412565e0/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 309 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20061026/412565e0/attachment.sig>
-------------- next part --------------
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
-------------- next part --------------
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


More information about the NumPy-Discussion mailing list