Skip to content

Commit

Permalink
Add a progress bar to 06.
Browse files Browse the repository at this point in the history
  • Loading branch information
kalekundert committed Jan 17, 2018
1 parent 178f693 commit 87a94b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions pull_into_place/commands/06_pick_designs_to_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,17 @@ def main():

# Remove designs that aren't in the Pareto front.

def progress(i, depth, j, front): #
sys.stderr.write('\x1b[2K\r minus Pareto dominated: calculating... [{}/{}] [{}/{}]'.format(i, depth, j, front))
if i == depth and j == front:
sys.stderr.write('\x1b[2K\r')
sys.stderr.flush()

seqs_scores = structures.find_pareto_front(
seqs_scores, score_metadata, metrics,
depth=int(args['--depth']),
epsilon=float(args['--epsilon']),
progress=progress,
)
print ' minus Pareto dominated: ', len(seqs_scores)

Expand Down
12 changes: 10 additions & 2 deletions pull_into_place/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def xyz_to_array(xyz):
return np.array([float(x) for x in xyz])


def find_pareto_front(metrics, metadata, columns, depth=1, epsilon=1e-7):
def find_pareto_front(metrics, metadata, columns, depth=1, epsilon=1e-7, progress=None):
"""
Return the subset of the given metrics that are Pareto optimal with respect
to the given columns.
Expand Down Expand Up @@ -428,6 +428,13 @@ def find_pareto_front(metrics, metadata, columns, depth=1, epsilon=1e-7):
(even if it is non-dominated). This is roughly in units of percent of
the range of the points.
progress: func
A function that will be called in the innermost loop as follows:
`progress(curr_depth, tot_depth, curr_hit, tot_hits)`. This is
primarily intended to allow the caller to present a progress bar, since
increasing the depth can dramatically increase the amount of time this
function takes.
Returns
=======
front: DataFrame
Expand Down Expand Up @@ -488,7 +495,8 @@ def boxify(df): #
# points that are rejected for being too similar at one depth will be
# included in the next depth.
front_boxes = boxify(metrics[mask])
for i, row in front_boxes.iterrows():
for j, (_, row) in enumerate(front_boxes.iterrows()):
if progress: progress(i+1, depth, j+1, len(front_boxes))
too_close |= all_boxes.apply(
lambda x: (x == row).all(), axis='columns')

Expand Down

0 comments on commit 87a94b6

Please sign in to comment.