[Numpy-svn] r3599 - trunk/numpy/core

numpy-svn@scip... numpy-svn@scip...
Mon Mar 26 14:23:06 CDT 2007


Author: charris
Date: 2007-03-26 14:23:04 -0500 (Mon, 26 Mar 2007)
New Revision: 3599

Modified:
   trunk/numpy/core/defmatrix.py
Log:
Fix errors involving matrix*sparse

Modified: trunk/numpy/core/defmatrix.py
===================================================================
--- trunk/numpy/core/defmatrix.py	2007-03-25 23:12:00 UTC (rev 3598)
+++ trunk/numpy/core/defmatrix.py	2007-03-26 19:23:04 UTC (rev 3599)
@@ -154,12 +154,12 @@
 
 
     def __mul__(self, other):
-        if not isscalar(other) :
-            try :
-                other = asmatrix(other)
-            except :
-                return NotImplemented
-        return N.dot(self, other)
+        if isinstance(other,(N.ndarray, list, tuple)) :
+            # This promotes 1-D vectors to row vectors
+            return N.dot(self, asmatrix(other))
+        if N.isscalar(other) or not hasattr(other, '__rmul__') :
+            return N.dot(self, other)
+        return NotImplemented
 
     def __rmul__(self, other):
         return N.dot(other, self)



More information about the Numpy-svn mailing list