Advertisement
Guest User

sad code

a guest
Feb 26th, 2013
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. import itertools as it
  2. import numpy as np
  3. l = input('How many lattices?_')
  4. m = input('How many markers?_')
  5. sums = list()
  6. pos = 1
  7. neg = -1
  8. L = list(it.product([-1,1], repeat =l))
  9. M = range(0,l) # makes a list from 0 to l-1, giving l entries, starting with 0 just like the indices of the lattices.
  10. Markers = list(it.combinations(M, m))
  11. i = 0
  12. j = 0
  13. k = 0
  14. while i < len(L):
  15.     Ring = L[i]
  16.     while j < len(Markers):
  17.         while k < 2*len(Ring):
  18.             Marker = Markers[j]
  19.             Ring = list(np.roll(Ring,1))
  20.             for x in Marker:
  21.                 t = Ring.pop(x)
  22.                 if t < 0:
  23.                     Ring.insert(x,pos)
  24.                 elif t > 0:
  25.                     Ring.insert(x,neg)
  26.                 else:
  27.                     print('This is why we cant have nice things...')
  28.             sums.append(abs(sum(Ring)))
  29.             k = k + 1
  30.         j = j + 1
  31.         k = 0
  32.     i = i + 1
  33.     j = 0
  34.     k = 0
  35.          
  36. print 'Average deviation: ', np.mean(sums)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement