[SciPy-User] Problem with IndexError
Krystian Rosiński
krystian.rosinski@gmail....
Fri Mar 25 14:26:29 CDT 2011
Thank you, your advice is very helpful and explains a lot. By the way
I've learned to use debugger in Spyder IDE.
On 25 Mar, 04:32, Robert Kern <robert.k...@gmail.com> wrote:
> 1. Unrelated, but important: on line 205, use zeros((1,6), dtype=int).
> Be sure to do this with other zeros() calls that are intended to hold
> indices. The default is dtype=float.
>
> 2. In pf_getdof(), I'm sure you want dof[0, 0:3] and dof[0, 3:6].
>
> 3. In pf_ssm(), you want range(nmem), not (0, nmem+1).
>
> 4. In pf_calclm(), since numpy is 0-indexed, you want to increment nd
> *after* you assign it into lm.
>
> 5. Typos: ilod -> iload, iloads -> iload.
>
> 6. In pf_assemloadvec():
>
> am = - dot(r.T, memloads[iload, 1:7])
> ii = dof[0, i]
>
> 7. Never use np.dot(np.linalg.inv(A), b). Use np.linalg.solve(A, b).
> You still have a singular matrix. This may or may not indicate further
> errors in your code, but that requires more knowledge of the problem
> and algorithm than I have.
>
> 8. As a matter of good style, don't use "from numpy import *". Use
> "import numpy as np" and use the dotted notation to get to numpy
> functions.
>
> I figured most of this out using pdb, Python's standard debugger. I
> didn't even look at the original. You can see a tutorial on using the
> debugger from the Software Carpentry site:
>
> http://software-carpentry.org/4_0/python/debugger/
More information about the SciPy-User
mailing list