Ticket #1162 (closed defect: fixed)
linalg.matrix_power crashes with nested list input
| Reported by: | dgoldsmith | Owned by: | somebody |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | numpy.linalg | Version: | |
| Keywords: | matrix_power, array_like | Cc: | d_l_goldsmith@… |
Description
linalg.matrix_power raises an AttributeError? when a nested list is passed in as the array argument:
Microsoft Windows [Version 6.0.6002] Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:\Users\DG>python Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
import numpy as np from numpy import linalg as LA LA.matrix_power([[1, 2], [3, 4]], 3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module> File "C:\Python25\Lib\site-packages\numpy\core\defmatrix.py", line 118, in matrix_power
AttributeError?: 'list' object has no attribute 'shape'
Yet the doc states:
matrix_power(M, n)
Raise a square matrix to the (integer) power n.
:
Parameters ---------- M : array_like
I've corrected the doc, for now, but I assume this actually a code bug.
