def test_plot_correlations_invalid_input_type_raises_error(
        series_to_plot, valid_data_types):
    # TODO: Is it possible to dynamically create the matching str if it includes
    #       characters that need to be escaped (like .)
    # match = f"Data must be a one of {valid_data_types}, but found type: {type(Z)}"
    with pytest.raises((TypeError, ValueError)):
        plot_correlations(series_to_plot)
Exemple #2
0
def test_plot_correlations_runs_without_error(series_to_plot):
    """Tests whether plot_correlations runs without error."""
    _check_soft_dependencies("matplotlib")
    import matplotlib.pyplot as plt

    plot_correlations(series_to_plot)
    plt.gcf().canvas.draw_idle()
Exemple #3
0
def test_plot_correlations_arguments(series_to_plot, lags, suptitle,
                                     series_title):
    """Tests whether plot_lags run with different input arguments."""
    _check_soft_dependencies("matplotlib")
    import matplotlib.pyplot as plt

    plot_correlations(series_to_plot,
                      lags=lags,
                      suptitle=suptitle,
                      series_title=series_title)
    plt.gcf().canvas.draw_idle()
    plt.close()
def test_plot_correlations_output_type(series_to_plot):
    _check_soft_dependencies("matplotlib")
    import matplotlib.pyplot as plt

    fig, ax = plot_correlations(series_to_plot)

    is_fig_figure = isinstance(fig, plt.Figure)
    is_ax_array = isinstance(ax, np.ndarray)
    is_ax_array_axis = all([isinstance(ax_, plt.Axes) for ax_ in ax])

    assert is_fig_figure and is_ax_array and is_ax_array_axis, "".join([
        "plot_correlations should return plt.Figure and array of plt.Axes,",
        f"but returned: {type(fig)} and {type(ax)}",
    ])