-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathtest_marginals.py
26 lines (20 loc) · 1 KB
/
test_marginals.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import plotly.express as px
import pytest
@pytest.mark.parametrize("px_fn", [px.scatter, px.density_heatmap, px.density_contour])
@pytest.mark.parametrize("marginal_x", [None, "histogram", "box", "violin"])
@pytest.mark.parametrize("marginal_y", [None, "rug"])
def test_xy_marginals(backend, px_fn, marginal_x, marginal_y):
df = px.data.tips(return_type=backend)
fig = px_fn(
df, x="total_bill", y="tip", marginal_x=marginal_x, marginal_y=marginal_y
)
assert len(fig.data) == 1 + (marginal_x is not None) + (marginal_y is not None)
@pytest.mark.parametrize("px_fn", [px.histogram, px.ecdf])
@pytest.mark.parametrize("marginal", [None, "rug", "histogram", "box", "violin"])
@pytest.mark.parametrize("orientation", ["h", "v"])
def test_single_marginals(backend, px_fn, marginal, orientation):
df = px.data.tips(return_type=backend)
fig = px_fn(
df, x="total_bill", y="total_bill", marginal=marginal, orientation=orientation
)
assert len(fig.data) == 1 + (marginal is not None)