summaryrefslogtreecommitdiff
path: root/numpy/matrixlib
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2017-08-06 11:36:11 -0500
committerGitHub <noreply@github.com>2017-08-06 11:36:11 -0500
commitf307cec3962926558b6387ebb4ab8d3f4ea3aa34 (patch)
treeb902a845cb2b7a64f78aae7a10776c3daeb16e50 /numpy/matrixlib
parentd6539868b353e211b4aaa3a683101e094b3ee1df (diff)
parent091b8c3b16d39d18f6921f9a17d06c1652b40dca (diff)
downloadnumpy-f307cec3962926558b6387ebb4ab8d3f4ea3aa34.tar.gz
Merge pull request #9505 from eric-wieser/fix-issubdtype
BUG: issubdtype is inconsistent on types and dtypes
Diffstat (limited to 'numpy/matrixlib')
-rw-r--r--numpy/matrixlib/defmatrix.py2
-rw-r--r--numpy/matrixlib/tests/test_defmatrix.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/numpy/matrixlib/defmatrix.py b/numpy/matrixlib/defmatrix.py
index 2aed3ebde..e016b5f4c 100644
--- a/numpy/matrixlib/defmatrix.py
+++ b/numpy/matrixlib/defmatrix.py
@@ -137,7 +137,7 @@ def matrix_power(M, n):
M = asanyarray(M)
if M.ndim != 2 or M.shape[0] != M.shape[1]:
raise ValueError("input must be a square array")
- if not issubdtype(type(n), int):
+ if not issubdtype(type(n), N.integer):
raise TypeError("exponent must be an integer")
from numpy.linalg import inv
diff --git a/numpy/matrixlib/tests/test_defmatrix.py b/numpy/matrixlib/tests/test_defmatrix.py
index e4c3c49fb..77f262031 100644
--- a/numpy/matrixlib/tests/test_defmatrix.py
+++ b/numpy/matrixlib/tests/test_defmatrix.py
@@ -249,6 +249,12 @@ class TestAlgebra(object):
assert_array_almost_equal(m4, np.dot(m2, m2))
assert_array_almost_equal(np.dot(mi, m), np.eye(2))
+ def test_scalar_type_pow(self):
+ m = matrix([[1, 2], [3, 4]])
+ for scalar_t in [np.int8, np.uint8]:
+ two = scalar_t(2)
+ assert_array_almost_equal(m ** 2, m ** two)
+
def test_notimplemented(self):
'''Check that 'not implemented' operations produce a failure.'''
A = matrix([[1., 2.],