Repository: sympy/sympy

Issue:
Odd behavior with Matrix*list
```
>>> M = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> v = [1, 1, 1]
>>> M*v
Matrix([
[                                                      [1, 1, 1],                                                       [1, 1, 1, 1, 1, 1],                                                       [1, 1, 1, 1, 1, 1, 1, 1, 1]],
[                           [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                            [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                            [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],
[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]])
```

This is based on the example in the Matrix.dot docstring. The result should probably be an exception, or an automatic conversion of the list to a matrix. The matrix of lists is wrong, and I'm surprised it's even allowed. 

Discussion:
vishalg2235: ping @asmeurer 
asmeurer: Looks good other than those comments. 

Patch:
diff --git a/.mailmap b/.mailmap
index 5852ce7cd2..e56279a1cf 100644
--- a/.mailmap
+++ b/.mailmap
@@ -367,8 +367,3 @@ Rob Drynkin <rob.drynkin@gmail.com>
 Unknown <kunda@scribus.net>
 Sayan Goswami <Sayan98@users.noreply.github.com>
 Subhash Saurabh <subhashsaurabh419@gmail.com>
-Vishal <vishalg2235@gmail.com>
-Jeremey Gluck <jeremygluck@yahoo.com>
-Akshat Maheshwari <akshat14714@gmail.com>
-Poom Chiarawongse <eight1911@gmail.com> <Eight1911@users.noreply.github.com>
-Poom Chiarawongse <eight1911@gmail.com> <15707729+Eight1911@users.noreply.github.com>
diff --git a/AUTHORS b/AUTHORS
index 12c3393c8e..4d5a5acbd7 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -4,7 +4,7 @@ those who explicitly didn't want to be mentioned. People with a * next
 to their names are not found in the metadata of the git history. This
 file is generated automatically by running `./bin/authors_update.py`.
 
-There are a total of 692 authors.
+There are a total of 685 authors.
 
 Ondřej Čertík <ondrej@certik.cz>
 Fabian Pedregosa <fabian@fseoane.net>
@@ -654,7 +654,7 @@ Cezary Marczak <zeddq1@gmail.com>
 dps7ud <dps7ud@virginia.edu>
 Nilabja Bhattacharya <nilabja10201992@gmail.com>
 Itay4 <31018228+Itay4@users.noreply.github.com>
-Poom Chiarawongse <eight1911@gmail.com>
+Poom Chiarawongse <Eight1911@users.noreply.github.com>
 Yang Yang <wdscxsj@gmail.com>
 Cavendish McKay <cmckay@tachycline.com>
 Bradley Gannon <bradley.m.gannon@gmail.com>
@@ -691,10 +691,3 @@ Jonathan A. Gross <jarthurgross@gmail.com>
 Unknown <kunda@scribus.net>
 Sayan Goswami <Sayan98@users.noreply.github.com>
 Subhash Saurabh <subhashsaurabh419@gmail.com>
-Rastislav Rabatin <rastislav.rabatin@gmail.com>
-Vishal <vishalg2235@gmail.com>
-Jeremey Gluck <jeremygluck@yahoo.com>
-Akshat Maheshwari <akshat14714@gmail.com>
-symbolique <symbolique@users.noreply.github.com>
-Saloni Jain <tosalonijain@gmail.com>
-Arighna Chakrabarty <arighna.chakrabarty100@gmail.com>
diff --git a/bin/mailmap_update.py b/bin/mailmap_update.py
index 3f8a066b2f..c7e1e2cc21 100755
--- a/bin/mailmap_update.py
+++ b/bin/mailmap_update.py
@@ -121,11 +121,9 @@ def author_name(line):
 
 # put entries in order -- this will help the user
 # to see if there are already existing entries for an author
-file = codecs.open(os.path.realpath(os.path.join(
+lines = codecs.open(os.path.realpath(os.path.join(
         __file__, os.path.pardir, os.path.pardir, ".mailmap")),
-        "r", "utf-8").read()
-blankline = not file or file.endswith('\n')
-lines = file.splitlines()
+        "r", "utf-8").read().splitlines()
 def key(line):
     # return lower case first address on line or
     # raise an error if not an entry
@@ -164,7 +162,7 @@ def short_entry(line):
         out.extend(long)
         out.extend(short)
 
-if out != lines or not blankline:
+if out != lines:
     # write lines
     with codecs.open(os.path.realpath(os.path.join(
             __file__, os.path.pardir, os.path.pardir, ".mailmap")),
@@ -172,9 +170,6 @@ def short_entry(line):
         fd.write('\n'.join(out))
         fd.write('\n')
     print()
-    if out != lines:
-        print(yellow('.mailmap lines were re-ordered.'))
-    else:
-        print(yellow('blank line added to end of .mailmap'))
+    print(yellow('.mailmap lines were re-odered.'))
 
 sys.exit(sysexit)
diff --git a/sympy/matrices/common.py b/sympy/matrices/common.py
index 8c4e21fcfb..379a2917aa 100644
--- a/sympy/matrices/common.py
+++ b/sympy/matrices/common.py
@@ -2018,12 +2018,14 @@ def __mul__(self, other):
         if getattr(other, 'is_MatrixLike', False):
             return MatrixArithmetic._eval_matrix_mul(self, other)
 
-        try:
-            return self._eval_scalar_mul(other)
-        except TypeError:
-            pass
+        # if 'other' is not iterable then scalar multiplication.
+        if not isinstance(other, collections.Iterable):
+            try:
+                return self._eval_scalar_mul(other)
+            except TypeError:
+                pass
 
-        raise TypeError('Cannot multiply %s and %s' % (type(self), type(other)))
+        return NotImplemented
 
     def __neg__(self):
         return self._eval_scalar_mul(-1)
@@ -2084,12 +2086,14 @@ def __rmul__(self, other):
         if getattr(other, 'is_MatrixLike', False):
             return MatrixArithmetic._eval_matrix_rmul(self, other)
 
-        try:
-            return self._eval_scalar_rmul(other)
-        except TypeError:
-            pass
+        # if 'other' is not iterable then scalar multiplication.
+        if not isinstance(other, collections.Iterable):
+            try:
+                return self._eval_scalar_rmul(other)
+            except TypeError:
+                pass
 
-        raise TypeError('Cannot multiply %s and %s' % (type(self), type(other)))
+        return NotImplemented
 
     @call_highest_priority('__sub__')
     def __rsub__(self, a):


Test patch:
diff --git a/sympy/geometry/tests/test_line.py b/sympy/geometry/tests/test_line.py
index 7a47addf8f..57dfc9bf8c 100644
--- a/sympy/geometry/tests/test_line.py
+++ b/sympy/geometry/tests/test_line.py
@@ -76,8 +76,7 @@ def test_arbitrary_point():
     assert Segment3D(Point3D(x1, x1, x1), Point3D(y1, y1, y1)).length == sqrt(3) * sqrt((x1 - y1) ** 2)
     assert Segment3D((1, 1, 1), (2, 3, 4)).arbitrary_point() == \
            Point3D(t + 1, 2 * t + 1, 3 * t + 1)
-    raises(ValueError, (lambda: Line((x, 1), (2, 3)).arbitrary_point(x)))
-
+    raises(ValueError, (lambda: Line((x,1),(2,3)).arbitrary_point(x)))
 
 def test_are_concurrent_2d():
     l1 = Line(Point(0, 0), Point(1, 1))
diff --git a/sympy/matrices/tests/test_commonmatrix.py b/sympy/matrices/tests/test_commonmatrix.py
index a7554d9295..27d9726464 100644
--- a/sympy/matrices/tests/test_commonmatrix.py
+++ b/sympy/matrices/tests/test_commonmatrix.py
@@ -1340,3 +1340,9 @@ def test_limit():
     x, y = symbols('x y')
     m = CalculusOnlyMatrix(2, 1, [1/x, y])
     assert m.limit(x, 5) == Matrix(2, 1, [S(1)/5, y])
+
+def test_issue_13774():
+    M = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
+    v = [1,1,1]
+    raises(TypeError, lambda: M*v)
+    raises(TypeError, lambda: v*M)
diff --git a/sympy/physics/tests/test_secondquant.py b/sympy/physics/tests/test_secondquant.py
index e9407239e2..bb532430ad 100644
--- a/sympy/physics/tests/test_secondquant.py
+++ b/sympy/physics/tests/test_secondquant.py
@@ -1231,6 +1231,5 @@ def test_canonical_ordering_AntiSymmetricTensor():
     k, l = symbols(('k','l'), below_fermi=True,
                                    cls=Dummy)
 
-    # formerly, the left gave either the left or the right
-    assert AntiSymmetricTensor(v, (k, l), (d, c)
-        ) == -AntiSymmetricTensor(v, (l, k), (d, c))
+    assert AntiSymmetricTensor(v, (k, l), (d, c)) == -AntiSymmetricTensor(v, (l, k), (d, c))
+    # Gives AntiSymTensor(kl,dc) or -AntiSymTensor(lk,dc) randomly between runs.