def cluster_info(self): """ Print some info about the clusters file. """ from monty.pprint import pprint_table tab_ = [] print('There are {} clusters:'.format(self.size())) for points, number in sorted(self._cluster_info.items()): singular = int(number) == 1 col1 = 'There {}:'.format('is' if singular else 'are') col2 = '{}'.format(number) col3 = '{}-point cluster{}'.format(points, ' ' if singular else 's') tab_.append([col1, col2, col3]) pprint_table(tab_, out=sys.stdout)
def compute_hints(ecuts, etotals, atols_mev, min_numpts=1, stream=sys.stdout): de_low, de_normal, de_high = [a / (1000 * Ha_to_eV) for a in atols_mev] etotal_inf = etotals[-1] ihigh = check_conv(etotals, de_high, min_numpts=min_numpts) inormal = check_conv(etotals, de_normal) ilow = check_conv(etotals, de_low) accidx = {"H": ihigh, "N": inormal, "L": ilow} table = []; app = table.append app(["iter", "ecut", "etotal", "et-e_inf [meV]", "accuracy",]) for idx, (ec, et) in enumerate(zip(ecuts, etotals)): line = "%d %.1f %.7f %.3f" % (idx, ec, et, (et-etotal_inf) * Ha_to_eV * 1.e+3) row = line.split() + ["".join(c for c, v in accidx.items() if v == idx)] app(row) if stream is not None: pprint_table(table, out=stream) ecut_high, ecut_normal, ecut_low = 3 * (None,) exit = (ihigh != -1) if exit: ecut_low = ecuts[ilow] ecut_normal = ecuts[inormal] ecut_high = ecuts[ihigh] aug_ratios = [1, ] aug_ratio_low, aug_ratio_normal, aug_ratio_high = 3 * (1,) #if not monotonic(etotals, mode="<", atol=1.0e-5): # logger.warning("E(ecut) is not decreasing") # wf_results.push_exceptions("E(ecut) is not decreasing:\n" + str(etotals)) return AttrDict( exit=ihigh != -1, etotals=list(etotals), ecuts=list(ecuts), aug_ratios=aug_ratios, low={"ecut": ecut_low, "aug_ratio": aug_ratio_low}, normal={"ecut": ecut_normal, "aug_ratio": aug_ratio_normal}, high={"ecut": ecut_high, "aug_ratio": aug_ratio_high})
def show_character_table(self, stream=sys.stdout): """Write a string with the character_table on the given stream.""" table = self.character_table pprint_table(table, out=stream)
def test_print(self): table = [["one", "two"], ["1", "2"]] pprint_table(table)