Skip to content

Commit

Permalink
avoid recomputing random district
Browse files Browse the repository at this point in the history
  • Loading branch information
daureg committed Nov 10, 2014
1 parent 1c8be77 commit bf77d36
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions significance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,24 @@ def mock_random_list(city, district, city_info):
city, districts = sys.argv[1], []
city_info = load_data(city)
gold_list = city_info[-1]
districts = sorted(gold_list.keys())
districts = sorted([nn for nn, gold in gold_list.iteritems()
if city in gold['gold']])
try:
os.mkdir('random')
except OSError:
pass
for district in districts:
savename = 'random/{}_{}.my'.format(city, district)
print(savename)
if os.path.isfile(savename):
continue
distrib, best_score, best_region = [], 0, None
for i in range(NTEST):
regions, score = mock_random_list(city, district, city_info)
if score > best_score:
best_score, best_region = score, regions
distrib.append(score)
p.save_var('random/{}_{}.my'.format(city, district), distrib)
p.save_var(savename, distrib)
outjson = [{
'pos': rank+1, 'metric': 'random', 'dst': -1, 'venues': r[1],
'geo': mapping(Polygon(np.fliplr(c.euclidean_to_geo(city, r[0]))))}
Expand Down

0 comments on commit bf77d36

Please sign in to comment.