Skip to content

Commit 97b214e

Browse files
ci: add test for perf warning
1 parent 940f25b commit 97b214e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Diff for: packages/python/plotly/plotly/tests/test_optional/test_px/test_px_wide.py

+28
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import plotly.express as px
22
import plotly.graph_objects as go
33
import pandas as pd
4+
import numpy as np
45
from plotly.express._core import build_dataframe, _is_col_list
56
from pandas.testing import assert_frame_equal
67
import pytest
8+
import warnings
79

810

911
def test_is_col_list():
@@ -847,3 +849,29 @@ def test_line_group():
847849
assert len(fig.data) == 4
848850
fig = px.scatter(df, x="x", y=["miss", "score"], color="who")
849851
assert len(fig.data) == 2
852+
853+
854+
def test_no_pd_perf_warning():
855+
n_cols = 1000
856+
n_rows = 1000
857+
858+
columns = list(f"col_{c}" for c in range(n_cols))
859+
index = list(f"i_{r}" for r in range(n_rows))
860+
861+
df = pd.DataFrame(
862+
np.random.uniform(size=(n_rows, n_cols)), index=index, columns=columns
863+
)
864+
865+
with warnings.catch_warnings(record=True) as warn_list:
866+
_ = px.bar(
867+
df,
868+
x=df.index,
869+
y=df.columns[:-2],
870+
labels=df.columns[:-2],
871+
)
872+
performance_warnings = [
873+
warn
874+
for warn in warn_list
875+
if issubclass(warn.category, pd.errors.PerformanceWarning)
876+
]
877+
assert len(performance_warnings) == 0, "PerformanceWarning(s) raised!"

0 commit comments

Comments
 (0)