def test_plot_intermediate_values( plotter: Callable[[_IntermediatePlotInfo], Any], info: _IntermediatePlotInfo ) -> None: figure = plotter(info) if isinstance(figure, go.Figure): figure.write_image(BytesIO()) else: plt.savefig(BytesIO())
def test_plot_param_importances( plot_param_importances: Callable[..., Any], specific_create_study: Callable[[], Study], params: Optional[List[str]], ) -> None: study = specific_create_study() figure = plot_param_importances(study, params=params) if isinstance(figure, go.Figure): figure.write_image(BytesIO()) else: plt.savefig(BytesIO())
def test_get_optimization_history_plot( target_name: str, info_list: List[_OptimizationHistoryInfo]) -> None: figure = _get_optimization_history_plot(info_list, target_name=target_name) assert figure.get_ylabel() == target_name expected_legends = [] for info in info_list: expected_legends.append(info.values_info.label_name) if info.best_values_info is not None: expected_legends.append(info.best_values_info.label_name) legends = [legend.get_text() for legend in figure.legend().get_texts()] assert sorted(legends) == sorted(expected_legends) plt.savefig(BytesIO())
def test_get_pareto_front_plot( plotter: Callable[[_ParetoFrontInfo], Any], info_template: _ParetoFrontInfo, include_dominated_trials: bool, has_constraints_func: bool, ) -> None: info = info_template if not include_dominated_trials: info = info._replace(include_dominated_trials=False, non_best_trials_with_values=[]) if not has_constraints_func: info = info._replace(has_constraints_func=False, infeasible_trials_with_values=[]) figure = plotter(info) if isinstance(figure, go.Figure): figure.write_image(BytesIO()) else: plt.savefig(BytesIO())
def save_static_image(figure: Union[go.Figure, Axes, np.ndarray]) -> None: if isinstance(figure, go.Figure): figure.write_image(BytesIO()) else: plt.savefig(BytesIO())