示例#1
0
def test_pairplot_outputs():
    X = np.random.rand(15, 3)
    Y = ["A"] * 5 + ["B"] * 5 + ["C"] * 5
    col_names = ["Feature1", "Feature2", "Feature3"]

    fig = pairplot(X)
    fig = pairplot(X, Y)
    fig = pairplot(X, Y, col_names)
    fig = pairplot(
        X, Y, col_names, title="Test", height=1.5, variables=["Feature1", "Feature2"]
    )
示例#2
0
    def test_common_inputs(self):
        X = er_np(100, 0.5)
        x = np.random.rand(100, 1)
        y = np.random.rand(100, 1)
        grid_labels = ["Test1"]

        # test figsize
        figsize = "bad figsize"
        with self.assertRaises(TypeError):
            heatmap(X, figsize=figsize)
        with self.assertRaises(beartype.roar.BeartypeCallHintParamViolation):
            with self.assertRaises(TypeError):
                networkplot(adjacency=X, x=x, y=y, figsize=figsize)

        # test height
        height = "1"
        with self.assertRaises(TypeError):
            gridplot([X], grid_labels, height=height)
        with self.assertRaises(TypeError):
            pairplot(X, height=height)

        # test title
        title = 1
        with self.assertRaises(TypeError):
            heatmap(X, title=title)
        with self.assertRaises(TypeError):
            gridplot([X], grid_labels, title=title)
        with self.assertRaises(TypeError):
            pairplot(X, title=title)
        with self.assertRaises(beartype.roar.BeartypeCallHintParamViolation):
            with self.assertRaises(TypeError):
                networkplot(adjacency=X, x=x, y=y, title=title)

        # test context
        context = 123
        with self.assertRaises(TypeError):
            heatmap(X, context=context)
        with self.assertRaises(TypeError):
            gridplot([X], grid_labels, context=context)
        with self.assertRaises(TypeError):
            pairplot(X, context=context)
        with self.assertRaises(beartype.roar.BeartypeCallHintParamViolation):
            with self.assertRaises(TypeError):
                networkplot(adjacency=X, x=x, y=y, context=context)

        context = "journal"
        with self.assertRaises(ValueError):
            heatmap(X, context=context)
        with self.assertRaises(ValueError):
            gridplot([X], grid_labels, context=context)
        with self.assertRaises(ValueError):
            pairplot(X, context=context)
        with self.assertRaises(ValueError):
            networkplot(adjacency=X, x=x, y=y, context=context)

        # test font scales
        font_scales = ["1", []]
        for font_scale in font_scales:
            with self.assertRaises(TypeError):
                heatmap(X, font_scale=font_scale)
            with self.assertRaises(TypeError):
                gridplot([X], grid_labels, font_scale=font_scale)
            with self.assertRaises(TypeError):
                pairplot(X, font_scale=font_scale)
            with self.assertRaises(
                    beartype.roar.BeartypeCallHintParamViolation):
                with self.assertRaises(TypeError):
                    networkplot(adjacency=X, x=x, y=y, font_scale=font_scale)

        # ticklabels
        with self.assertRaises(TypeError):
            xticklabels = "labels"
            yticklabels = "labels"
            heatmap(X, xticklabels=xticklabels, yticklabels=yticklabels)

        with self.assertRaises(ValueError):
            xticklabels = ["{}".format(i) for i in range(5)]
            yticklabels = ["{}".format(i) for i in range(5)]
            heatmap(X, xticklabels=xticklabels, yticklabels=yticklabels)

        with self.assertRaises(TypeError):
            heatmap(X, title_pad="f")

        with self.assertRaises(TypeError):
            gridplot([X], title_pad="f")

        with self.assertRaises(TypeError):
            heatmap(X, hier_label_fontsize="f")

        with self.assertRaises(TypeError):
            gridplot([X], hier_label_fontsize="f")
示例#3
0
    def test_pairplot_inputs(self):
        X = np.random.rand(15, 3)
        Y = ["A"] * 5 + ["B"] * 5 + ["C"] * 5

        # test data
        with self.assertRaises(TypeError):
            pairplot(X="test")

        with self.assertRaises(ValueError):
            pairplot(X=X, labels=["A"])

        with self.assertRaises(TypeError):
            pairplot(X, col_names="A")

        with self.assertRaises(ValueError):
            pairplot(X, col_names=["1", "2"])

        with self.assertRaises(ValueError):
            pairplot(X, col_names=["1", "2", "3"], variables=[1, 2, 3, 4])

        with self.assertRaises(KeyError):
            pairplot(X, col_names=["1", "2", "3"], variables=["A", "B"])
示例#4
0
def test_common_inputs():
    X = er_np(100, 0.5)
    grid_labels = ["Test1"]

    # test figsize
    with pytest.raises(TypeError):
        figsize = "bad figsize"
        heatmap(X, figsize=figsize)

    # test height
    height = "1"
    with pytest.raises(TypeError):
        gridplot([X], grid_labels, height=height)
    with pytest.raises(TypeError):
        pairplot(X, height=height)

    # test title
    title = 1
    with pytest.raises(TypeError):
        heatmap(X, title=title)
    with pytest.raises(TypeError):
        gridplot([X], grid_labels, title=title)
    with pytest.raises(TypeError):
        pairplot(X, title=title)

    # test context
    context = 123
    with pytest.raises(TypeError):
        heatmap(X, context=context)
    with pytest.raises(TypeError):
        gridplot([X], grid_labels, context=context)
    with pytest.raises(TypeError):
        pairplot(X, context=context)

    context = "journal"
    with pytest.raises(ValueError):
        heatmap(X, context=context)
    with pytest.raises(ValueError):
        gridplot([X], grid_labels, context=context)
    with pytest.raises(ValueError):
        pairplot(X, context=context)

    # test font scales
    font_scales = ["1", []]
    for font_scale in font_scales:
        with pytest.raises(TypeError):
            heatmap(X, font_scale=font_scale)
        with pytest.raises(TypeError):
            gridplot([X], grid_labels, font_scale=font_scale)
        with pytest.raises(TypeError):
            pairplot(X, cont_scale=font_scale)

    # ticklabels
    with pytest.raises(TypeError):
        xticklabels = "labels"
        yticklabels = "labels"
        heatmap(X, xticklabels=xticklabels, yticklabels=yticklabels)

    with pytest.raises(ValueError):
        xticklabels = ["{}".format(i) for i in range(5)]
        yticklabels = ["{}".format(i) for i in range(5)]
        heatmap(X, xticklabels=xticklabels, yticklabels=yticklabels)

    with pytest.raises(TypeError):
        heatmap(X, title_pad="f")

    with pytest.raises(TypeError):
        gridplot([X], title_pad="f")

    with pytest.raises(TypeError):
        heatmap(X, hier_label_fontsize="f")

    with pytest.raises(TypeError):
        gridplot([X], hier_label_fontsize="f")