Ejemplo n.º 1
0
def test_figure_categorical_cluster(data):
    cr = dd.correlation_matrix(data, cluster=True, categorical=True)
    assert isinstance(cr.show(viz_backend="plotly"), plotly.graph_objs.Figure)
    assert isinstance(cr.show(), mpl_plot)
    assert _is_dataframe(cr.association_matrix)
    assert _is_dataframe(cr.association_matrix)
    assert _is_dataframe(cr.viz_data)
    assert isinstance(cr, CorrelationWidget)
    assert_frame_equal(cr.viz_data, cr.cluster_matrix)
Ejemplo n.º 2
0
def test_cluster_no_categorical_figure(data):
    cr = dd.correlation_matrix(data, cluster=True)
    assert isinstance(cr.show(viz_backend="plotly"), plotly.graph_objs.Figure)
    assert isinstance(cr.show(), mpl_plot)
    assert _is_dataframe(cr.association_matrix)
    assert _is_dataframe(cr.viz_data)
    assert isinstance(cr, CorrelationWidget)
    assert_frame_equal(cr.viz_data, cr.cluster_matrix)
    assert data.select_dtypes(["number"]).shape[1] == cr.association_matrix.shape[1]
    assert data.select_dtypes(["number"]).shape[1] == cr.association_matrix.shape[0]
    assert data.select_dtypes(["number"]).shape[1] == cr.viz_data.shape[1]
    assert data.select_dtypes(["number"]).shape[1] == cr.viz_data.shape[0]
Ejemplo n.º 3
0
def test_categorical_and_numerical_data(data):
    cr = dd.correlation_matrix(data, categorical=True)
    assert isinstance(cr.show(viz_backend="plotly"), plotly.graph_objs.Figure)
    assert isinstance(cr.show(), mpl_plot)
    assert _is_dataframe(cr.association_matrix)
    assert _is_dataframe(cr.viz_data)
    assert isinstance(cr, CorrelationWidget)
    assert_frame_equal(cr.viz_data, cr.association_matrix)
    assert data.shape[1] == cr.association_matrix.shape[1]
    assert data.shape[1] == cr.association_matrix.shape[0]
    assert data.shape[1] == cr.viz_data.shape[1]
    assert data.shape[1] == cr.viz_data.shape[0]
    assert isinstance(cr.cluster_matrix, type(None))
Ejemplo n.º 4
0
def test_categorical_data_only(data):
    cat_data = data[
        [c for c in data.columns if c not in data.select_dtypes(["number"]).columns]
    ]
    cr = dd.correlation_matrix(cat_data, categorical=True)
    assert isinstance(cr.show(viz_backend="plotly"), plotly.graph_objs.Figure)
    assert isinstance(cr.show(), mpl_plot)
    assert _is_dataframe(cr.association_matrix)
    assert _is_dataframe(cr.viz_data)
    assert isinstance(cr, CorrelationWidget)
    assert_frame_equal(cr.viz_data, cr.association_matrix)
    assert cat_data.shape[1] == cr.association_matrix.shape[1]
    assert cat_data.shape[1] == cr.association_matrix.shape[0]
    assert cat_data.shape[1] == cr.viz_data.shape[1]
    assert cat_data.shape[1] == cr.viz_data.shape[0]
    assert isinstance(cr.cluster_matrix, type(None))
Ejemplo n.º 5
0
def test_not_df():
    with pytest.raises(ValueError):
        dd.correlation_matrix("this_is_a_string")
Ejemplo n.º 6
0
def test_numeric_data_only_but_specified_categorical(data):
    num_data = data.select_dtypes(["number"])
    with pytest.warns(UserWarning):
        dd.correlation_matrix(num_data, categorical=True)
Ejemplo n.º 7
0
def test_categorical_data_only_but_specified_numeric(data):
    num_data = data.select_dtypes(["number"])
    cat_data = data[[c for c in data.columns if c not in num_data.columns]]
    with pytest.raises(ValueError):
        dd.correlation_matrix(cat_data)