[Numpy-discussion] linked variables?
Tue Jun 3 16:19:10 CDT 2008
Its probably something simple I don't understand but...
I've written a dummy function which takes an array m. I'd like it to
return a changed array m_i, and not change the initial array m. I
call it with mm = dummy(m);
3 from numpy import *;
4 def dummy(m):
5 m_o = m;
7 m_step = 100;
8 m_i = m_o;
9 dummy = m;
10 dummy2 = m_o;
11 dummy3 = m_o;
12 i = 0;
13 m_i[i] = m_i[i] + m_step;
But after line 13 m, m_o, dummy, dummy2, and dummy3 are all changed
by m_step, as well mm which is in a different name space. All I've
asked it to do is change m_i. What's happening?
University of Utah
Department of Geology and Geophysics
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion