[Matrix-SIG] NumPy inconsistency?

Just van Rossum just@letterror.com
Mon, 14 Dec 1998 13:57:51 +0100


Is there a reason why adding a 2-tuple to 2d array is allowed but
multiplying a 2d array by a 2-tuple isn't? See here:


>>> from Numeric import *
>>> a = arange(6)
>>> a.shape = -1,2
>>> a
array([[0, 1],
       [2, 3],
       [4, 5]])
>>> a + (1.5, 2.0)
array([[ 1.5,  3. ],
       [ 3.5,  5. ],
       [ 5.5,  7. ]])
>>> a * (1.5, 2.0)
Traceback (innermost last):
  File "<input>", line 1, in ?
TypeError: can't multiply sequence with non-int
>>>



Just