[PYTHON MATRIX-SIG] Something broken with __mul__?
tim@lassi.ece.uiuc.edu
tim@lassi.ece.uiuc.edu
Fri, 18 Oct 1996 12:00:38 -0500
Konrad Hinsen writes:
<...>
>Just to add *why* multiplication with * fails: it doesn't
>accept an integer and a Float32 as arguments. Making either
>or both arguments float solves the problem.
I just looked and PyArray_CanCastSafely in arrayobject.c is set up
only to allow conversions from ints, longs, etc. to doubles, not to
floats. Why? I'm betting it's a typo, but I've been known to be wrong
before. If int->float is meant to be allowed, it's an easy fix:
case PyArray_LONG:
return (totype > PyArray_FLOAT);
is changed to:
case PyArray_LONG:
return (totype >= PyArray_FLOAT);
in lines 1709-10 of arrayobject.c.
>I don't remember exactly the result of the long debate about
>coercion and combination of different data types, but somehow
>I think this is not correct...
That would be my guess as well...
--
-tim
+--------------------------------------------------------------------+
| Tim Hochberg Ultrahigh Speed Digital Electronics Lab |
| tim@lassi.ece.uiuc.edu University of Illinois |
| http://dogbert.ece.uiuc.edu/~tim (217) 333-6014 |
+--------------------------------------------------------------------+
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================