Skip to content

Commit 4b22199

Browse files
Merge branch 'master' into one_group_short_circuit
2 parents f46f809 + a4b9887 commit 4b22199

File tree

7 files changed

+60
-36
lines changed

7 files changed

+60
-36
lines changed

Diff for: CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
56
## UNRELEASED
67

78
### Added
89

910
- `pattern_shape` options now available in `px.timeline()` [#3774](https://github.com/plotly/plotly.py/pull/3774)
11+
- `facet_*` and `category_orders` now available in `px.pie()` [#3775](https://github.com/plotly/plotly.py/pull/3775)
1012

1113
### Performance
1214

1315
- `px` methods no longer call `groupby` on the input dataframe when the result would be a single group, and no longer groups by a lambda, for significant speedups [#3765](https://github.com/plotly/plotly.py/pull/3765)
1416

17+
### Updated
18+
19+
- Allow non-string extras in `flaglist` attributes, to support upcoming changes to `ax.automargin` in plotly.js [plotly.js#6193](https://github.com/plotly/plotly.js/pull/6193), [#3749](https://github.com/plotly/plotly.py/pull/3749)
20+
1521
## [5.8.2] - 2022-06-10
1622

1723
### Fixed
@@ -22,7 +28,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2228

2329
(no changes, due to a mixup with the build process!)
2430

25-
2631
## [5.8.0] - 2022-05-09
2732

2833
### Fixed

Diff for: packages/python/plotly/_plotly_utils/basevalidators.py

+8-13
Original file line numberDiff line numberDiff line change
@@ -1795,8 +1795,6 @@ def __init__(
17951795
self.extras = extras if extras is not None else []
17961796
self.array_ok = array_ok
17971797

1798-
self.all_flags = self.flags + self.extras
1799-
18001798
def description(self):
18011799

18021800
desc = (
@@ -1835,24 +1833,21 @@ def description(self):
18351833
return desc
18361834

18371835
def vc_scalar(self, v):
1836+
if isinstance(v, str):
1837+
v = v.strip()
1838+
1839+
if v in self.extras:
1840+
return v
1841+
18381842
if not isinstance(v, str):
18391843
return None
18401844

18411845
# To be generous we accept flags separated on plus ('+'),
1842-
# or comma (',')
1846+
# or comma (',') and we accept whitespace around the flags
18431847
split_vals = [e.strip() for e in re.split("[,+]", v)]
18441848

18451849
# Are all flags valid names?
1846-
all_flags_valid = all([f in self.all_flags for f in split_vals])
1847-
1848-
# Are any 'extras' flags present?
1849-
has_extras = any([f in self.extras for f in split_vals])
1850-
1851-
# For flaglist to be valid all flags must be valid, and if we have
1852-
# any extras present, there must be only one flag (the single extras
1853-
# flag)
1854-
is_valid = all_flags_valid and (not has_extras or len(split_vals) == 1)
1855-
if is_valid:
1850+
if all(f in self.flags for f in split_vals):
18561851
return "+".join(split_vals)
18571852
else:
18581853
return None

Diff for: packages/python/plotly/_plotly_utils/tests/validators/test_flaglist_validator.py

+16-17
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,45 @@
44
import numpy as np
55

66

7+
EXTRAS = ["none", "all", True, False, 3]
8+
FLAGS = ["lines", "markers", "text"]
9+
710
# Fixtures
811
# --------
9-
@pytest.fixture(params=[None, ["none", "all"]])
12+
@pytest.fixture(params=[None, EXTRAS])
1013
def validator(request):
1114
# Validator with or without extras
12-
return FlaglistValidator(
13-
"prop", "parent", flags=["lines", "markers", "text"], extras=request.param
14-
)
15+
return FlaglistValidator("prop", "parent", flags=FLAGS, extras=request.param)
1516

1617

1718
@pytest.fixture()
1819
def validator_extra():
19-
return FlaglistValidator(
20-
"prop", "parent", flags=["lines", "markers", "text"], extras=["none", "all"]
21-
)
20+
return FlaglistValidator("prop", "parent", flags=FLAGS, extras=EXTRAS)
2221

2322

2423
@pytest.fixture()
2524
def validator_extra_aok():
2625
return FlaglistValidator(
2726
"prop",
2827
"parent",
29-
flags=["lines", "markers", "text"],
30-
extras=["none", "all"],
28+
flags=FLAGS,
29+
extras=EXTRAS,
3130
array_ok=True,
3231
)
3332

3433

3534
@pytest.fixture(
3635
params=[
3736
"+".join(p)
38-
for i in range(1, 4)
39-
for p in itertools.permutations(["lines", "markers", "text"], i)
37+
for i in range(1, len(FLAGS) + 1)
38+
for p in itertools.permutations(FLAGS, i)
4039
]
4140
)
4241
def flaglist(request):
4342
return request.param
4443

4544

46-
@pytest.fixture(params=["none", "all"])
45+
@pytest.fixture(params=EXTRAS)
4746
def extra(request):
4847
return request.param
4948

@@ -69,7 +68,7 @@ def test_coercion(in_val, coerce_val, validator):
6968

7069

7170
# ### Rejection by type ###
72-
@pytest.mark.parametrize("val", [21, (), ["lines"], set(), {}])
71+
@pytest.mark.parametrize("val", [(), ["lines"], set(), {}])
7372
def test_rejection_type(val, validator):
7473
with pytest.raises(ValueError) as validation_failure:
7574
validator.validate_coerce(val)
@@ -79,7 +78,7 @@ def test_rejection_type(val, validator):
7978

8079
# ### Rejection by value ###
8180
@pytest.mark.parametrize(
82-
"val", ["", "line", "markers+line", "lin es", "lin es+markers"]
81+
"val", ["", "line", "markers+line", "lin es", "lin es+markers", 21]
8382
)
8483
def test_rejection_val(val, validator):
8584
with pytest.raises(ValueError) as validation_failure:
@@ -144,7 +143,7 @@ def test_acceptance_aok_scalarlist_flaglist(flaglist, validator_extra_aok):
144143
[
145144
["all", "markers", "text+markers"],
146145
["lines", "lines+markers", "markers+lines+text"],
147-
["all", "all", "lines+text", "none"],
146+
["all", "all", "lines+text"] + EXTRAS,
148147
],
149148
)
150149
def test_acceptance_aok_list_flaglist(val, validator_extra_aok):
@@ -158,8 +157,8 @@ def test_acceptance_aok_list_flaglist(val, validator_extra_aok):
158157
"in_val,expected",
159158
[
160159
(
161-
[" lines ", " lines + markers ", "lines ,markers"],
162-
["lines", "lines+markers", "lines+markers"],
160+
[" lines ", " lines + markers ", "lines ,markers", " all "],
161+
["lines", "lines+markers", "lines+markers", "all"],
163162
),
164163
(np.array(["text +lines"]), np.array(["text+lines"], dtype="unicode")),
165164
],

Diff for: packages/python/plotly/plotly/express/_chart_types.py

+6
Original file line numberDiff line numberDiff line change
@@ -1452,11 +1452,17 @@ def pie(
14521452
names=None,
14531453
values=None,
14541454
color=None,
1455+
facet_row=None,
1456+
facet_col=None,
1457+
facet_col_wrap=0,
1458+
facet_row_spacing=None,
1459+
facet_col_spacing=None,
14551460
color_discrete_sequence=None,
14561461
color_discrete_map=None,
14571462
hover_name=None,
14581463
hover_data=None,
14591464
custom_data=None,
1465+
category_orders=None,
14601466
labels=None,
14611467
title=None,
14621468
template=None,

Diff for: packages/python/plotly/plotly/express/_core.py

+18
Original file line numberDiff line numberDiff line change
@@ -1686,6 +1686,22 @@ def process_dataframe_timeline(args):
16861686
return args
16871687

16881688

1689+
def process_dataframe_pie(args, trace_patch):
1690+
names = args.get("names")
1691+
if names is None:
1692+
return args, trace_patch
1693+
order_in = args["category_orders"].get(names, {}).copy()
1694+
if not order_in:
1695+
return args, trace_patch
1696+
df = args["data_frame"]
1697+
trace_patch["sort"] = False
1698+
trace_patch["direction"] = "clockwise"
1699+
uniques = list(df[names].unique())
1700+
order = [x for x in OrderedDict.fromkeys(list(order_in) + uniques) if x in uniques]
1701+
args["data_frame"] = df.set_index(names).loc[order].reset_index()
1702+
return args, trace_patch
1703+
1704+
16891705
def infer_config(args, constructor, trace_patch, layout_patch):
16901706
attrs = [k for k in direct_attrables + array_attrables if k in args]
16911707
grouped_attrs = []
@@ -1974,6 +1990,8 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
19741990
args = build_dataframe(args, constructor)
19751991
if constructor in [go.Treemap, go.Sunburst, go.Icicle] and args["path"] is not None:
19761992
args = process_dataframe_hierarchy(args)
1993+
if constructor in [go.Pie]:
1994+
args, trace_patch = process_dataframe_pie(args, trace_patch)
19771995
if constructor == "timeline":
19781996
constructor = go.Bar
19791997
args = process_dataframe_timeline(args)

Diff for: packages/python/plotly/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def get_latest_publish_build_info(repo, branch):
286286

287287
url = (
288288
r"https://circleci.com/api/v1.1/project/github/"
289-
r"{repo}/tree/{branch}?limit=10000\&filter=completed"
289+
r"{repo}/tree/{branch}?limit=100&filter=completed"
290290
).format(repo=repo, branch=branch)
291291

292292
branch_jobs = request_json(url)

Diff for: release.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ Publishing to `plotly` conda channel (make sure you have run `conda install anac
131131
start by doing it first if not. Then merge `master` into `doc-prod` to deploy the doc related
132132
to features in the release.
133133
3. in a clone of the [`graphing-library-docs` repo](https://github.com/plotly/graphing-library-docs):
134-
1. bump the version of Plotly.js with `cd _data && python get_plotschema.py <PLOTLY.JS VERSION>` fixing any errors that come up
135-
2. rebuild the Algolia `schema` index with `ALGOLIA_API_KEY=<key> make update_ref_search`
136-
3. Rebuild the Algolia `python` index with `ALGOLIA_API_KEY=<key> make update_python_search`
137-
4. Commit and push the changes to `master` in that repo
134+
1. bump the version of Plotly.py in `_data/pyversion.json`
135+
2. bump the version of Plotly.js with `cd _data && python get_plotschema.py <PLOTLY.JS VERSION>` fixing any errors that come up
136+
3. rebuild the Algolia `schema` index with `ALGOLIA_API_KEY=<key> make update_ref_search`
137+
4. Rebuild the Algolia `python` index with `ALGOLIA_API_KEY=<key> make update_python_search`
138+
5. Commit and push the changes to `master` in that repo
138139

139140
### Notify Stakeholders
140141

0 commit comments

Comments
 (0)