MCPcopy Create free account
hub / github.com/MAC-VO/MAC-VO / plot_histogram

Function plot_histogram

Utility/Plot/PlotAxes.py:180–193  ·  view source on GitHub ↗
(ax: Axes, data: torch.Tensor | np.ndarray | list[float], bins: tuple[T.Literal["num", "width"], float], **hist_kwargs)

Source from the content-addressed store, hash-verified

178@as_chain_func
179@IgnoreException
180def plot_histogram(ax: Axes, data: torch.Tensor | np.ndarray | list[float], bins: tuple[T.Literal["num", "width"], float], **hist_kwargs) -> Axes:
181 if isinstance(data, torch.Tensor):
182 data = data.detach().cpu().numpy()
183 if isinstance(data, np.ndarray):
184 data = data.flatten()
185
186 match bins:
187 case "num", bin_num:
188 bin_num = int(bin_num)
189 ax.hist(data, bins=bin_num, **hist_kwargs)
190 case "width", bin_width:
191 ax.hist(data, bins=np.arange(min(data), max(data) + bin_width, bin_width).tolist(), **hist_kwargs)
192
193 return ax
194
195@as_chain_func
196@IgnoreException

Callers 1

plot_flow_performanceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected