Skip to content

Commit 03847dc

Browse files
committed
Large cleanup with the code. Now it mostly follows pep convention
1 parent d331886 commit 03847dc

File tree

5 files changed

+164
-162
lines changed

5 files changed

+164
-162
lines changed

seatingchart/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
__author__ = 'davidruffner'
2+
+19-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import seatingchart as sc
2-
import random
1+
import seatingchart.seatingchart as sc
32
import numpy as np
43
import matplotlib.pyplot as plt
54
import copy
@@ -12,18 +11,16 @@
1211
nguests = len(guestlist.guests)
1312
seatsper = 5
1413

15-
chart = sc.SeatingChart(guestlist,nguests/seatsper,seatsper)
16-
chart0=copy.deepcopy(chart)
14+
chart = sc.SeatingChart(guestlist, nguests/seatsper, seatsper)
15+
chart0 = copy.deepcopy(chart)
1716
print ''
1817
print "Guests to be seated and their friends"
1918

20-
org = sc.Organizer(guestlist,chart)
21-
org0 = sc.Organizer(guestlist,chart0)
22-
#Seat everyone
19+
org = sc.Organizer(guestlist, chart)
20+
org0 = sc.Organizer(guestlist, chart0)
21+
# Seat everyone
2322
org.seatguests()
2423

25-
26-
2724
print "The final seating chart"
2825
chart.print_seatingchart()
2926
chart.print_chart()
@@ -39,29 +36,27 @@
3936
friendsT2 = np.zeros(nsteps)
4037
friendsT3 = np.zeros(nsteps)
4138
for i in steps:
42-
friendsT1[i] = org1.metropolisstep(0.01)
43-
friendsT2[i] = org2.metropolisstep(.1)
44-
friendsT3[i] = org3.metropolisstep(1)
39+
friendsT1[i] = org1.metropolisstep(temp=0.01)
40+
friendsT2[i] = org2.metropolisstep(temp=.1)
41+
friendsT3[i] = org3.metropolisstep(temp=1)
4542

46-
#Now compare to what happens if i just seat people with friends
43+
# Now compare to what happens if i just seat people with friends
4744
org0.sc.print_chart()
4845
org0.seatguestsfriends()
49-
count=org0.friendcount()
46+
count = org0.friendcount()
5047
print "Number of friends with seating with friends method"
5148
print count
52-
print "friends T1,T2,T3"
53-
print [friendsT1[-1],friendsT2[-1],friendsT3[-1]]
54-
plt.plot(steps, friendsT1,label='T1')
55-
plt.plot(steps, friendsT2,label='T2')
56-
plt.plot(steps, friendsT3,label='T3')
57-
plt.legend( loc='upper left')
58-
plt.xlabel="step"
59-
plt.ylabel="friendships"
49+
print "friends T1, T2, T3"
50+
print [friendsT1[-1], friendsT2[-1], friendsT3[-1]]
51+
plt.plot(steps, friendsT1, label='T1')
52+
plt.plot(steps, friendsT2, label='T2')
53+
plt.plot(steps, friendsT3, label='T3')
54+
plt.legend(loc='upper left')
55+
plt.xlabel = "step"
56+
plt.ylabel = "friendships"
6057

6158
org0.sc.to_excel('SeatingChart0.xlsx')
6259
org1.sc.to_excel('SeatingChart1.xlsx')
6360

6461

6562
plt.show()
66-
67-

0 commit comments

Comments
 (0)