def test_plot_data_with_xmax(base_dict, plot_method, mock_figure): fig = plot_method(**base_dict, xmax=20) assert (fig._actual_fig == mock_figure # pylint: disable=protected-access ), "Figure is different than expected" ax = mock_figure.add_subplot.return_value assert_calls(ax.set_xlim, [([], dict(left=0.1)), ([], dict(right=20))], rel=EPSILON)
def test_plot_data_without_boundaries(base_dict, plot_method, mock_figure): fig = plot_method(**base_dict) assert fig == mock_figure, "Figure is different than expected" ax = mock_figure.add_subplot.return_value assert_calls( ax.set_xlim, [([], dict(left=0.1)), ([], dict(right=10.9))], rel=EPSILON )
def test_plot_residuals_with_xmax(base_dict, plot_method, mock_figure): fig = plot_method(**base_dict, xmax=20) assert fig == mock_figure, "Figure is different than expected" ax = mock_figure.add_subplot.return_value assert_calls(ax.hlines, [([0], dict(xmin=0.1, xmax=20, linestyles="dashed"))], rel=EPSILON)
def test_plot_residuals_with_xmin(base_dict, plot_method, mock_figure): fig = plot_method(**base_dict, xmin=-10) assert (fig._actual_fig == mock_figure # pylint: disable=protected-access ), "Figure is different than expected" ax = mock_figure.add_subplot.return_value assert_calls(ax.hlines, [([0], dict(xmin=-10, xmax=10.9, linestyles="dashed"))], rel=EPSILON)
def test_residuals_error_bar(base_dict, plot_method, mock_figure): fig = plot_method(**base_dict) assert fig == mock_figure, "Figure is different than expected" y_residuals = cases.FIT_DATA.y - cases.FUNC(cases.A, cases.FIT_DATA.x) ax = mock_figure.add_subplot.return_value assert_calls( ax.errorbar, [ ( [], dict( x=cases.FIT_DATA.x, y=y_residuals, xerr=cases.FIT_DATA.xerr, yerr=cases.FIT_DATA.yerr, markersize=1, marker="o", linestyle="None", ), ), ], rel=EPSILON, )
def test_plot_fitting_without_boundaries(kwargs, plot_calls, figure): plot_fitting(data=FIT_DATA, func=FUNC, title_name=TITLE_NAME, **kwargs) ax = figure.add_subplot.return_value assert_calls(ax.plot, plot_calls, rel=EPSILON)