Repository: sympy/sympy

Issue:
Potential Bug in sympy/tensor/array/array_derivatives.py
I was doing some static analysis and found an if statement that looks like a bug on line 112: https://github.com/sympy/sympy/blob/b0a27be36c69dc48d7b2145be82b77d5bffc56a0/sympy/tensor/array/array_derivatives.py#L115
```python
if isinstance(expr, MatrixCommon) or isinstance(expr, MatrixCommon):
```
 , but both sides of that expression are redundant. Is it suppose to be?
```python
if isinstance(expr, MatrixCommon) or isinstance(v, MatrixCommon):
```

Discussion:

Patch:
diff --git a/sympy/tensor/array/array_derivatives.py b/sympy/tensor/array/array_derivatives.py
index 797d5c1f6b..b12b64d1ad 100644
--- a/sympy/tensor/array/array_derivatives.py
+++ b/sympy/tensor/array/array_derivatives.py
@@ -112,7 +112,7 @@ def _dispatch_eval_derivative_n_times(cls, expr, v, count):
                 return None
         else:
             # Both `expr` and `v` are some array/matrix type:
-            if isinstance(expr, MatrixCommon) or isinstance(expr, MatrixCommon):
+            if isinstance(expr, MatrixCommon) or isinstance(v, MatrixCommon):
                 result = derive_by_array(expr, v)
             elif isinstance(expr, MatrixExpr) and isinstance(v, MatrixExpr):
                 result = cls._call_derive_default(expr, v)


Test patch:
diff --git a/sympy/tensor/array/tests/test_array_derivatives.py b/sympy/tensor/array/tests/test_array_derivatives.py
index cc220c0d33..4a3232bc08 100644
--- a/sympy/tensor/array/tests/test_array_derivatives.py
+++ b/sympy/tensor/array/tests/test_array_derivatives.py
@@ -48,5 +48,5 @@ def test_array_derivative_construction():
     d = ArrayDerivative(M.as_explicit(), (N.as_explicit(), 2), evaluate=False)
     assert d.doit().shape == (4, 3, 4, 3, 3, 2)
     expr = d.doit()
-    assert isinstance(expr, ArrayDerivative)
+    assert isinstance(expr, NDimArray)
     assert expr.shape == (4, 3, 4, 3, 3, 2)