コード例 #1
0
def test_pairwise_density_plot_not_numeric(artworks_df, artworks_summary):
    plt.cla()

    def mock_render(fig):
        assert False

    explorer = Explorer(artworks_summary, plot_renderer=mock_render)
    with pytest.raises(ValueError):
        explorer.pairwise_density_plot("Diameter (cm)", "Nationality")
コード例 #2
0
def test_pairwise_density_plot_both_categorical(artworks_df, artworks_summary):
    plt.cla()

    def mock_render(fig):
        #  currently pairwise_density_plot returns a plotly figure
        assert len(fig["data"]) == 1
        data = fig["data"][0]
        assert data["type"] == "heatmap"

    explorer = Explorer(artworks_summary, plot_renderer=mock_render)
    explorer.pairwise_density_plot("Nationality", "Gender")
コード例 #3
0
def test_pairwise_density_plot(artworks_df, artworks_summary):
    plt.cla()

    def mock_render(fig):
        #  currently pairwise_density_plot returns a plotly figure
        assert len(fig['data']) == 1
        data = fig['data'][0]
        assert data['type'] == 'heatmap'

    explorer = Explorer(artworks_summary, plot_renderer=mock_render)
    explorer.pairwise_density_plot('Width (cm)', 'Height (cm)')
コード例 #4
0
def test_correlation_plot_include(artworks_df, artworks_summary):
    plt.cla()

    def mock_render(fig):
        assert len(fig['data']) == 1
        data = fig['data'][0]
        assert data['type'] == 'heatmap'
        assert set(data['y']) == set(data['x']) == {'Height (cm)'}

    explorer = Explorer(artworks_summary, plot_renderer=mock_render)
    explorer.correlation_plot(include=['Height (cm)'])
コード例 #5
0
def test_pairwise_density_plot_both_categorical(artworks_df, artworks_summary):
    plt.cla()

    def mock_render(fig):
        #  currently pairwise_density_plot returns a plotly figure
        assert len(fig['data']) == 1
        data = fig['data'][0]
        assert data['type'] == 'heatmap'

    explorer = Explorer(artworks_summary, plot_renderer=mock_render)
    explorer.pairwise_density_plot('Nationality', 'Gender')
コード例 #6
0
def test_correlation_plot_exclude(artworks_df, artworks_summary):
    plt.cla()

    def mock_render(fig):
        assert len(fig['data']) == 1
        data = fig['data'][0]
        assert data['type'] == 'heatmap'
        expected_columns = {'Height (cm)', 'Depth (cm)'}
        assert set(data['y']) == set(data['x']) == expected_columns

    explorer = Explorer(artworks_summary, plot_renderer=mock_render)
    explorer.correlation_plot(exclude=['Width (cm)'])
コード例 #7
0
def test_correlation_plot_annotations(artworks_df, artworks_summary):
    plt.cla()

    def mock_render(fig):
        assert len(fig["data"]) == 1
        corr = [item for row in fig["data"][0]["z"] for item in row]
        labels = [l["text"] for l in fig["layout"]["annotations"]]
        for c, l in zip(corr, labels):
            assert "{:.2g}".format(c) == l

    explorer = Explorer(artworks_summary, plot_renderer=mock_render)
    explorer.correlation_plot(
        include=["Height (cm)", "Width (cm)", "Depth (cm)"])
    explorer.correlation_plot(include=["Height (cm)", "Width (cm)"])
コード例 #8
0
def test_correlation_plot_annotations(artworks_df, artworks_summary):
    plt.cla()

    def mock_render(fig):
        assert len(fig['data']) == 1
        corr = [item for row in fig['data'][0]['z'] for item in row]
        labels = [l['text'] for l in fig['layout']['annotations']]
        for c, l in zip(corr, labels):
            assert '{:.2g}'.format(c) == l

    explorer = Explorer(artworks_summary, plot_renderer=mock_render)
    explorer.correlation_plot(include=['Height (cm)', 'Width (cm)',
                                       'Depth (cm)'])
    explorer.correlation_plot(include=['Height (cm)', 'Width (cm)'])