Skip to content

Commit

Permalink
Merge branch 'master' into release-5.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LiamConnors committed Feb 15, 2024
2 parents b541a69 + 2451671 commit 4628ee6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
15 changes: 11 additions & 4 deletions packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
_subplot_type_for_trace_type,
)

pandas_2_2_0 = version.parse(pd.__version__) >= version.parse("2.2.0")

NO_COLOR = "px_no_color_constant"
trendline_functions = dict(
lowess=lowess, rolling=rolling, ewm=ewm, expanding=expanding, ols=ols
Expand Down Expand Up @@ -2068,10 +2070,15 @@ def get_groups_and_orders(args, grouper):
g.insert(i, "")
full_sorted_group_names = [tuple(g) for g in full_sorted_group_names]

groups = {
sf: grouped.get_group(s if len(s) > 1 else s[0])
for sf, s in zip(full_sorted_group_names, sorted_group_names)
}
groups = {}
for sf, s in zip(full_sorted_group_names, sorted_group_names):
if len(s) > 1:
groups[sf] = grouped.get_group(s)
else:
if pandas_2_2_0:
groups[sf] = grouped.get_group((s[0],))
else:
groups[sf] = grouped.get_group(s[0])
return groups, orders


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from plotly.express._core import build_dataframe
from pandas.testing import assert_frame_equal
import sys
import warnings


# Fixtures
Expand Down Expand Up @@ -667,3 +668,16 @@ def test_x_or_y(fn):
assert list(fig.data[0].x) == constant
assert list(fig.data[0].y) == categorical
assert fig.data[0].orientation == "h"


def test_no_futurewarning():
with warnings.catch_warnings(record=True) as warn_list:
_ = px.scatter(
x=[15, 20, 29],
y=[10, 20, 30],
color=["Category 1", "Category 2", "Category 1"],
)
future_warnings = [
warn for warn in warn_list if issubclass(warn.category, FutureWarning)
]
assert len(future_warnings) == 0, "FutureWarning(s) raised!"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
requests==2.25.1
tenacity==6.2.0
pandas==2.0.2
numpy==1.21.6
pandas==2.2.0
numpy==1.22.4
xarray==0.17.0
statsmodels
Pillow==8.2.0
Expand Down

0 comments on commit 4628ee6

Please sign in to comment.