Repository: sympy/sympy

Issue:
Collect assumes commutation
The following code, returns 0, for the collection of two operators a and ad that do not commute. 
```
from sympy.physics.quantum import Commutator, Dagger
from sympy import collect
from sympy.physics.quantum.boson import BosonOp

a = BosonOp("a")
ad = Dagger(a)
print(collect(a*ad-ad*a,a))
```

One can check that these operators are non-commutative by the following lines

`print(a.is_commutative)
print(ad.is_commutative)`

returning False

Discussion:

Patch:
diff --git a/sympy/simplify/radsimp.py b/sympy/simplify/radsimp.py
index 3c2c8b0e14..028d3a1e89 100644
--- a/sympy/simplify/radsimp.py
+++ b/sympy/simplify/radsimp.py
@@ -371,6 +371,9 @@ def parse_expression(terms, pattern):
                 print("DEBUG: returned %s" % str(result))
 
             if result is not None:
+                if not symbol.is_commutative:
+                    raise AttributeError("Can not collect noncommutative symbol")
+
                 terms, elems, common_expo, has_deriv = result
 
                 # when there was derivative in current pattern we


Test patch:
diff --git a/sympy/simplify/tests/test_radsimp.py b/sympy/simplify/tests/test_radsimp.py
index b4b2102411..dd8bc90461 100644
--- a/sympy/simplify/tests/test_radsimp.py
+++ b/sympy/simplify/tests/test_radsimp.py
@@ -5,7 +5,7 @@
 
 from sympy.core.mul import _unevaluated_Mul as umul
 from sympy.simplify.radsimp import _unevaluated_Add, collect_sqrt, fraction_expand
-from sympy.utilities.pytest import XFAIL
+from sympy.utilities.pytest import XFAIL, raises
 
 from sympy.abc import x, y, z, t, a, b, c, d, e, f, g, h, i, k
 
@@ -420,3 +420,11 @@ def test_issue_5933():
     x = Polygon(*RegularPolygon((0, 0), 1, 5).vertices).centroid.x
     assert abs(denom(x).n()) > 1e-12
     assert abs(denom(radsimp(x))) > 1e-12  # in case simplify didn't handle it
+
+
+def test_issue_14608():
+    a, b = symbols('a b', commutative=False)
+    x, y = symbols('x y')
+    raises(AttributeError, lambda: collect(a*b + b*a, a))
+    assert collect(x*y + y*(x+1), a) == x*y + y*(x+1)
+    assert collect(x*y + y*(x+1) + a*b + b*a, y) == y*(2*x + 1) + a*b + b*a