From: Bill B. <wb...@gm...> - 2006-02-20 07:37:19
|
Should have mentioned -- I was using numpy 0.9.4 / scipy 0.4.4. Looks like it works in numpy 0.9.5 / scipy 0.4.6 But matplotlib, which I also need, hasn't been updated for numpy 0.9.5 yet. :-( It's also still pretty weird to me that you have to do "from scipy.linalgimport lu" specifically. And then after doing that one import, then all the other scipy.linalg.* functions magically spring into existence too. Is tha= t sort of hing expected behavior from Python imports? >>> import numpy as N >>> import scipy as S >>> S.linalg.lu Traceback (most recent call last): File "<input>", line 1, in ? AttributeError: 'module' object has no attribute 'lu' >>> from scipy.linalg import lu >>> S.linalg.lu(N.rand(2,2)) (array([[ 0., 1.], [ 1., 0.]]), array([[ 1. , 0. ], [ 0.18553085, 1. ]]), array([[ 0.71732168, 0.48540043], [ 0. , 0.61379118]])) >>> (N.__version__, S.__version__) ('0.9.5', '0.4.6') --bb On 2/20/06, Nils Wagner <nw...@me...> wrote: > > Bill Baxter wrote: > > Ack. I may be able to get references to lu, lu_factor, et al, but > > they don't actually work with numpy arrays: > > > > from scipy.linalg import lu,lu_factor,lu_solve > > import scipy as S > > A =3D S.rand(2,2) > > lu(A) > > Traceback (most recent call last): > > File "<input>", line 1, in ? > > File "C:\Python24\Lib\site-packages\scipy\linalg\decomp.py", line > > 249, in lu > > flu, =3D get_flinalg_funcs(('lu',),(a1,)) > > File "C:\Python24\Lib\site-packages\scipy\linalg\flinalg.py", line > > 30, in get_flinalg_funcs > > t =3D arrays[i].dtypechar > > AttributeError: 'numpy.ndarray' object has no attribute 'dtypechar' > > > > > > Ok, so, once again, does anyone have an lu_factor / lu_solve > > implementation in python that I could borrow? > > > > Apologies for the monologue. > > > > --bb > > > > > > On 2/20/06, *Bill Baxter* <wb...@gm... > > <mailto:wb...@gm...>> wrote: > > > > Upon further inspection I find that if I call 'from scipy import > > *' then linalg.lu <http://linalg.lu> etc are defined. > > But if I do anything else to import scipy like 'import scipy' or > > 'import scipy as S' or 'from scipy import linalg', then lu, cg etc > > are not defined. > > > > Why is that? > > > > I can get at them without importing * by doing 'from scipy.linalg > > import lu', but that's kind of odd to have to do that. > > > > --bb > > > > > > On 2/20/06, * Bill Baxter* <wb...@gm... > > <mailto:wb...@gm...>> wrote: > > > > This url http://www.rexx.com/~dkuhlman/scipy_course_01.html > > <http://www.rexx.com/%7Edkuhlman/scipy_course_01.html> seems > > to keep turning up in my searches for numpy and scipy things, > > but many of the linalg operations it lists don't seem to exist > > in recent versions of numpy (or scipy). > > > > Some of them are: > > > > * norm > > * factorizations: lu, lu_factor, lu_solve, qr > > * iterative solvers: cg, cgs, gmres etc. > > > > Did these things used to exist in Numeric but they haven't > > been ported over? Will they be re-introduced sometime? > > > > In the short term, the one I'm after right now is LU decompose > > and solve functionality. Anyone have a numpy implementation? > > > > --Bill Baxter > > > No problem here. > > >>> from scipy.linalg import lu,lu_factor,lu_solve > >>> import scipy as S > >>> A =3D S.rand(2,2) > >>> lu(A) > (array([[ 0., 1.], > [ 1., 0.]]), array([[ 1. , 0. ], > [ 0.81367315, 1. ]]), array([[ 0.49886054, 0.57065709], > [ 0. , -0.30862809]])) > >>> S.__version__ > '0.4.7.1614' > > > Nils > > |