Skip to content

Instantly share code, notes, and snippets.

@kparrish
Created April 1, 2013 20:25
Show Gist options
  • Save kparrish/5287463 to your computer and use it in GitHub Desktop.
Save kparrish/5287463 to your computer and use it in GitHub Desktop.
Numpy Simple Swap Algorithm, avoid views.
def swap(array, index1, index2):
t = np.copy(array[index1])
array[index1] = array[index2]
array[index2] = t
return array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment