|
7 | 7 | import pytest |
8 | 8 | from packaging import version |
9 | 9 | import unittest.mock as mock |
10 | | -from plotly.express._core import build_dataframe |
| 10 | +from plotly.express._core import build_dataframe, _is_continuous |
11 | 11 | from plotly import optional_imports |
12 | 12 | from pandas.testing import assert_frame_equal |
13 | 13 | import sys |
@@ -624,6 +624,19 @@ def test_auto_orient_x_and_y(fn, x, y, result): |
624 | 624 | assert fn(x=series[x], y=series[y]).data[0].orientation == result |
625 | 625 |
|
626 | 626 |
|
| 627 | +@pytest.mark.parametrize("dtype", [nw.UInt8, nw.UInt16, nw.UInt32, nw.UInt64]) |
| 628 | +def test_auto_orient_unsigned_int(constructor, dtype): |
| 629 | + df = nw.from_native(constructor(dict(category=["a", "b", "c"], value=[1, 2, 3]))) |
| 630 | + df = df.with_columns(nw.col("value").cast(dtype)).to_native() |
| 631 | + |
| 632 | + assert _is_continuous(nw.from_native(df, eager_only=True), "value") |
| 633 | + fig = px.bar(df, x="category", y="value") |
| 634 | + assert fig.data[0].orientation == "v" |
| 635 | + assert list(fig.data[0].y) == [1, 2, 3] |
| 636 | + fig = px.bar(df, x="value", y="category") |
| 637 | + assert fig.data[0].orientation == "h" |
| 638 | + |
| 639 | + |
627 | 640 | def test_histogram_auto_orient(): |
628 | 641 | numerical = [1, 2, 3, 4] |
629 | 642 | assert px.histogram(x=numerical, nbins=5).data[0].nbinsx == 5 |
|
0 commit comments