title: python function globalizing input variables?
body: <p>I have a python function that solves matrix equations using Gaussian elimination with partial pivoting. I've been using it as part of a matrix solving module. When I use the Gaussian elimination function by passing it the matrix, called 'A' (a 2D numpy array), and vector of constants called 'b' (1D numpy array), the function seems to operate globally on the variables passed to it instead of using local variables. I am using the same name for the variables being passed to the function and the variables inside the function, but shouldn't the function be using copies of the variables passed to it?</p>
  
  <p>I think the issue might be with the "tuple exchanges." I know they do funky things with variable referencing but I'm not knowledgable enough to say exactly what is wrong here.</p>
  
  <p>The function:</p>
  
  <pre><code>def Gaussian_eliminiation(A,b):
      #Gaussian elimination with scaled partial pivoting
      n = len(b)
      #make sure the arrays are storing float variables and not integers
      if not A.dtype == float or b.dtype == float:
          print "Variables may be integers and not floats"
      #find scaling factors
      s = np.zeros((n,))
      for i in range(n):
      s[i] = max(abs(A[i,:]))
      #eliminate, moving through each pivot row with i
      for i in range(n-1):
          #put the correct pivot row in place
          (_, idx) = max_idx(abs(A[i:n,i])/s[i:n])
          idx += i
          if(idx != i):
              #swap values with tuple exchanges
              for j in range(i,n):
                  (A[i,j],A[idx,j]) = (A[idx,j],A[i,j])
              (b[i],b[idx]) = (b[idx],b[i])
              (s[i],s[idx]) = (s[idx],s[i])
          #use the pivot in row i to work on row j
          for j in range(i+1,n):
              m = A[j,i]/float(A[i,i])
              #operate on the elements of row j and the b vector
              A[j,i:] -= m*A[i,i:]
              b[j] -= m*b[i]
      if(A[n-1,n-1] == 0):
          print "\nThere is no unique solution to the matrix.",
          print "The final row is empty:\n",A,'&lt;--\n'
      return (A,b)
  </code></pre>