I'm in Python, and I've imported Numeric. And I'm on Fedora.
I'm trying to make a copy of a 3x3 array, modify the copy, then subtract the original array from the copy to see what's left. But every time I change the copy, the original changes too, so the final difference between the two 3x3 arrays is 0 in every element.
I looked around online and it looks like Python passes by reference, right? So whatever I do to the "copied" array is passed back to the original. I saw somewhere that
Expand|Select|Wrap|Line Numbers
- ..newarray = oldarray[:]..
Here's what I'm running:
Expand|Select|Wrap|Line Numbers
- ..sitewater=masterwater[:]
- print masterwater
- print sitewater
- sitewater[2,0]=3
- print sitewater
- print masterwater..
Expand|Select|Wrap|Line Numbers
- ..[[ 2.157016 0.931734 18.799198]
- [ 1.484143 2.309928 18.915375]
- [ 1.283086 1.359119 18.840746]]
- [[ 2.157016 0.931734 18.799198]
- [ 1.484143 2.309928 18.915375]
- [ 1.283086 1.359119 18.840746]]
- [[ 2.157016 0.931734 18.799198]
- [ 1.484143 2.309928 18.915375]
- [ 3. 1.359119 18.840746]]
- [[ 2.157016 0.931734 18.799198]
- [ 1.484143 2.309928 18.915375]
- [ 3. 1.359119 18.840746]]..
Thanks,
pholvey