Skip to content

Commit

Permalink
Merge branch 'master' into one_group_short_circuit
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaskruchten authored Jun 23, 2022
2 parents f46f809 + a4b9887 commit 4b22199
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 36 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).


## UNRELEASED

### Added

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

### Performance

- `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)

### Updated

- 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)

## [5.8.2] - 2022-06-10

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

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


## [5.8.0] - 2022-05-09

### Fixed
Expand Down
21 changes: 8 additions & 13 deletions packages/python/plotly/_plotly_utils/basevalidators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1795,8 +1795,6 @@ def __init__(
self.extras = extras if extras is not None else []
self.array_ok = array_ok

self.all_flags = self.flags + self.extras

def description(self):

desc = (
Expand Down Expand Up @@ -1835,24 +1833,21 @@ def description(self):
return desc

def vc_scalar(self, v):
if isinstance(v, str):
v = v.strip()

if v in self.extras:
return v

if not isinstance(v, str):
return None

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

# Are all flags valid names?
all_flags_valid = all([f in self.all_flags for f in split_vals])

# Are any 'extras' flags present?
has_extras = any([f in self.extras for f in split_vals])

# For flaglist to be valid all flags must be valid, and if we have
# any extras present, there must be only one flag (the single extras
# flag)
is_valid = all_flags_valid and (not has_extras or len(split_vals) == 1)
if is_valid:
if all(f in self.flags for f in split_vals):
return "+".join(split_vals)
else:
return None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,45 @@
import numpy as np


EXTRAS = ["none", "all", True, False, 3]
FLAGS = ["lines", "markers", "text"]

# Fixtures
# --------
@pytest.fixture(params=[None, ["none", "all"]])
@pytest.fixture(params=[None, EXTRAS])
def validator(request):
# Validator with or without extras
return FlaglistValidator(
"prop", "parent", flags=["lines", "markers", "text"], extras=request.param
)
return FlaglistValidator("prop", "parent", flags=FLAGS, extras=request.param)


@pytest.fixture()
def validator_extra():
return FlaglistValidator(
"prop", "parent", flags=["lines", "markers", "text"], extras=["none", "all"]
)
return FlaglistValidator("prop", "parent", flags=FLAGS, extras=EXTRAS)


@pytest.fixture()
def validator_extra_aok():
return FlaglistValidator(
"prop",
"parent",
flags=["lines", "markers", "text"],
extras=["none", "all"],
flags=FLAGS,
extras=EXTRAS,
array_ok=True,
)


@pytest.fixture(
params=[
"+".join(p)
for i in range(1, 4)
for p in itertools.permutations(["lines", "markers", "text"], i)
for i in range(1, len(FLAGS) + 1)
for p in itertools.permutations(FLAGS, i)
]
)
def flaglist(request):
return request.param


@pytest.fixture(params=["none", "all"])
@pytest.fixture(params=EXTRAS)
def extra(request):
return request.param

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


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

# ### Rejection by value ###
@pytest.mark.parametrize(
"val", ["", "line", "markers+line", "lin es", "lin es+markers"]
"val", ["", "line", "markers+line", "lin es", "lin es+markers", 21]
)
def test_rejection_val(val, validator):
with pytest.raises(ValueError) as validation_failure:
Expand Down Expand Up @@ -144,7 +143,7 @@ def test_acceptance_aok_scalarlist_flaglist(flaglist, validator_extra_aok):
[
["all", "markers", "text+markers"],
["lines", "lines+markers", "markers+lines+text"],
["all", "all", "lines+text", "none"],
["all", "all", "lines+text"] + EXTRAS,
],
)
def test_acceptance_aok_list_flaglist(val, validator_extra_aok):
Expand All @@ -158,8 +157,8 @@ def test_acceptance_aok_list_flaglist(val, validator_extra_aok):
"in_val,expected",
[
(
[" lines ", " lines + markers ", "lines ,markers"],
["lines", "lines+markers", "lines+markers"],
[" lines ", " lines + markers ", "lines ,markers", " all "],
["lines", "lines+markers", "lines+markers", "all"],
),
(np.array(["text +lines"]), np.array(["text+lines"], dtype="unicode")),
],
Expand Down
6 changes: 6 additions & 0 deletions packages/python/plotly/plotly/express/_chart_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1452,11 +1452,17 @@ def pie(
names=None,
values=None,
color=None,
facet_row=None,
facet_col=None,
facet_col_wrap=0,
facet_row_spacing=None,
facet_col_spacing=None,
color_discrete_sequence=None,
color_discrete_map=None,
hover_name=None,
hover_data=None,
custom_data=None,
category_orders=None,
labels=None,
title=None,
template=None,
Expand Down
18 changes: 18 additions & 0 deletions packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,22 @@ def process_dataframe_timeline(args):
return args


def process_dataframe_pie(args, trace_patch):
names = args.get("names")
if names is None:
return args, trace_patch
order_in = args["category_orders"].get(names, {}).copy()
if not order_in:
return args, trace_patch
df = args["data_frame"]
trace_patch["sort"] = False
trace_patch["direction"] = "clockwise"
uniques = list(df[names].unique())
order = [x for x in OrderedDict.fromkeys(list(order_in) + uniques) if x in uniques]
args["data_frame"] = df.set_index(names).loc[order].reset_index()
return args, trace_patch


def infer_config(args, constructor, trace_patch, layout_patch):
attrs = [k for k in direct_attrables + array_attrables if k in args]
grouped_attrs = []
Expand Down Expand Up @@ -1974,6 +1990,8 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
args = build_dataframe(args, constructor)
if constructor in [go.Treemap, go.Sunburst, go.Icicle] and args["path"] is not None:
args = process_dataframe_hierarchy(args)
if constructor in [go.Pie]:
args, trace_patch = process_dataframe_pie(args, trace_patch)
if constructor == "timeline":
constructor = go.Bar
args = process_dataframe_timeline(args)
Expand Down
2 changes: 1 addition & 1 deletion packages/python/plotly/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def get_latest_publish_build_info(repo, branch):

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

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

### Notify Stakeholders

Expand Down

0 comments on commit 4b22199

Please sign in to comment.