Function to resize global numpy array interactively in ipython
David Sanders
dpsanders at gmail.com
Mon Oct 29 02:53:34 EDT 2007
More information about the Python-list mailing list
Mon Oct 29 02:53:34 EDT 2007
- Previous message (by thread): Kudzu Version of SonomaSunshine
- Next message (by thread): Function to resize global numpy array interactively in ipython
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi, I have a script with function definitions which I load into ipython for interactive use. These functions modify a global numpy array, whose size I need to be able to change interactively. I thus have a script which looks like this: from numpy import * def do_resize(N): global a a = resize(a, N) a = array([]) N=10; do_resize(N) print "Length of a is: ", len(a) N=20; do_resize(N) print "Length of a is: ", len(a) If I run this in ipython, using "run resize.py", it correctly outputs 10 and then 20. If I now type *interactively* N=30; do_resize(N), then the length of a is still 20, rather than 30 as I was hoping -- somehow I seem to be now dealing with a different copy of a? Doing the same thing in idle works as I expect, i.e. interactively the size is changed to 30. Could somebody please explain what's going on, and how I solve the problem? Thanks and best wishes, David.
- Previous message (by thread): Kudzu Version of SonomaSunshine
- Next message (by thread): Function to resize global numpy array interactively in ipython
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list