MCPcopy Create free account
hub / github.com/JasonLSC/GSCodec_Studio / plot_grid

Function plot_grid

tools/static_bench/make_rd_curve.py:229–457  ·  view source on GitHub ↗
(
    results: OrderedDict,
    metric_keys: List[str],
    styles: Dict[str, Tuple[str, str, str]],
    method_groups: Dict[str, str],
    out_path: Path,
    dpi: int,
    show: bool,
)

Source from the content-addressed store, hash-verified

227
228
229def plot_grid(
230 results: OrderedDict,
231 metric_keys: List[str],
232 styles: Dict[str, Tuple[str, str, str]],
233 method_groups: Dict[str, str],
234 out_path: Path,
235 dpi: int,
236 show: bool,
237) -> None:
238 if not metric_keys:
239 raise ValueError("At least one metric must be provided.")
240
241 datasets = list(results.keys())
242 if not datasets:
243 raise ValueError("The input JSON does not contain any dataset entries.")
244
245 n_rows = len(datasets)
246 n_cols = len(metric_keys)
247
248 base_height = 3.0
249 base_width = base_height * (5.0 / 3.0)
250 fig_width = base_width * n_cols
251 fig_height = base_height * n_rows
252
253 fig, axes = plt.subplots(
254 n_rows,
255 n_cols,
256 figsize=(fig_width, fig_height),
257 squeeze=False,
258 gridspec_kw={"wspace": 0.22, "hspace": 0.32},
259 )
260
261 methods_with_points: set[str] = set()
262
263 grid_params = {
264 "linestyle": "--",
265 "alpha": 0.2,
266 "color": "gray",
267 "which": "both",
268 "zorder": 0,
269 }
270
271 for row_index, dataset_key in enumerate(datasets):
272 dataset_label = format_dataset_label(dataset_key)
273 dataset_results = results[dataset_key]
274
275 method_sizes: Dict[str, List[float]] = {}
276 method_metrics: Dict[str, Dict[str, List[float]]] = {
277 metric_key: {} for metric_key in metric_keys
278 }
279
280 for method, variants in dataset_results.items():
281 ordered = sorted(variants.values(), key=lambda values: values[3])
282 if not ordered:
283 continue
284
285 sizes = [values[3] for values in ordered]
286 method_sizes[method] = sizes

Callers 1

mainFunction · 0.85

Calls 3

format_dataset_labelFunction · 0.85
getMethod · 0.80
compute_limitsFunction · 0.70

Tested by

no test coverage detected