def log_remaining_rounds(ids, cluster_mapping, bail_out, log_fh=None):
 remaining_rounds = len([id for id in ids.keys() if (len(cluster_mapping[id]) >= bail_out)])
 if log_fh:
  log_fh.write(('Rounds remaining in worst case: %d\n' % remaining_rounds))
 return remaining_rounds

def log_remaining_rounds ( ids , cluster_mapping , bail_out , log_fh = None ) : remaining_rounds = len ( [ id for id in ids . keys ( ) if ( len ( cluster_mapping [ id ] ) >= bail_out ) ] ) if log_fh : log_fh . write ( ( 'Rounds remaining in worst case: %d\n' % remaining_rounds ) ) return remaining_rounds
estimate the worst case number of rounds remaining ids: dict of active ids cluster_mapping: cluster mapping as dict bail_out: minimally required cluster size log_fh: log file handle .