MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / quantile_breakdown

Function quantile_breakdown

scripts/meshstat.py:60–101  ·  view source on GitHub ↗
(data, name, info, title=None, with_total=True)

Source from the content-addressed store, hash-verified

58 info["bbox_max"] = bbox_max.tolist();
59
60def quantile_breakdown(data, name, info, title=None, with_total=True):
61 if title is None:
62 title = "{} info".format(name.capitalize());
63 print_section_header(title);
64 if len(data) == 0:
65 print_red("Empty");
66 return;
67
68 # Filter out inf/nan values.
69 is_valid = np.isfinite(data);
70 data = data[is_valid];
71 num_bad_values = len(is_valid) - len(data);
72 info["bad_{}".format(name)] = num_bad_values;
73 if not np.all(is_valid):
74 print_red("Skipping {} non-finite values".format(num_bad_values));
75
76 ave = np.mean(data);
77 ave_text = "ave: {:.6g}".format(ave);
78 print("{: <27}".format(ave_text), end="");
79 if with_total:
80 total = np.sum(data);
81 total_text = "total: {:.6g}".format(total);
82 print("{: >28}".format(total_text));
83 else:
84 print();
85
86 p0, p25, p50, p75, p90, p95, p100 =\
87 np.percentile(data, [0, 25, 50, 75, 90, 95, 100]);
88 table_format = "{:^7.3} {:^7.3} {:^7.3} {:^7.3} {:^7.3} {:^7.3} {:^7.3}";
89 print(table_format.format("min", "25%", "50%", "75%", "90%", "95%", "max"));
90 print(table_format.format(p0, p25, p50, p75, p90, p95, p100));
91
92 info["ave_{}".format(name)] = ave;
93 info["min_{}".format(name)] = p0;
94 info["p25_{}".format(name)] = p25;
95 info["median_{}".format(name)] = p50;
96 info["p75_{}".format(name)] = p75;
97 info["p90_{}".format(name)] = p90;
98 info["p95_{}".format(name)] = p95;
99 info["max_{}".format(name)] = p100;
100 if with_total:
101 info["total_{}".format(name)] = total;
102
103def print_edge_info(mesh, info):
104 if (mesh.num_faces == 0): return;

Callers 4

print_edge_infoFunction · 0.85
print_face_infoFunction · 0.85
print_quantile_infoFunction · 0.85
print_voxel_infoFunction · 0.85

Calls 2

print_redFunction · 0.90
print_section_headerFunction · 0.85

Tested by

no test coverage detected