Skip to content

Commit

Permalink
Made --prune stuff work more sensibly
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Mar 15, 2015
1 parent 20423ea commit 381db3b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions commands/run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ def validateRunArguments(tdb, cmdenv, calc):

if cmdenv.pruneScores and cmdenv.pruneHops:
if cmdenv.pruneScores > 100:
raise CommandLineError("--prune-score value percentage exceed 100.")
raise CommandLineError("--prune-score value percentile exceed 100.")
if cmdenv.pruneHops < 2:
raise CommandLineError("--prune-hops must 2 or more.")
else:
Expand Down Expand Up @@ -1024,12 +1024,9 @@ def run(results, cmdenv, tdb):

if pruneMod and hopNo + 1 >= cmdenv.pruneHops and len(routes) > 10:
routes.sort()
bestScore, worstScore = routes[0].score, routes[-1].score
threshold = bestScore * pruneMod
oldLen = len(routes)
while routes[-1].score < threshold:
routes.pop()
cmdenv.NOTE("Pruned {} origins", oldLen - len(routes))
crop = int(len(routes) * pruneMod)
routes = routes[:-crop]
cmdenv.NOTE("Pruned {} origins", crop)

if cmdenv.progress:
print("* Hop {:3n}: {:.>10n} origins".format(hopNo+1, len(routes)))
Expand Down

0 comments on commit 381db3b

Please sign in to comment.