Skip to content

Commit 506baca

Browse files
committed
Fix stacked barplot missing groups issue (#5428) and add test in test_plotly_express
1 parent 5cf0e93 commit 506baca

File tree

1,086 files changed

+5198
-2287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,086 files changed

+5198
-2287
lines changed

_plotly_utils/basevalidators.py

Lines changed: 72 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,9 @@ def __init__(self, plotly_name, parent_name, **kwargs):
411411
def description(self):
412412
return """\
413413
The '{plotly_name}' property is an array that may be specified as a tuple,
414-
list, numpy array, or pandas Series""".format(plotly_name=self.plotly_name)
414+
list, numpy array, or pandas Series""".format(
415+
plotly_name=self.plotly_name
416+
)
415417

416418
def validate_coerce(self, v):
417419
if is_none_or_typed_array_spec(v):
@@ -559,7 +561,9 @@ def description(self):
559561
desc
560562
+ """
561563
- One of the following enumeration values:
562-
{enum_vals_str}""".format(enum_vals_str=enum_vals_str)
564+
{enum_vals_str}""".format(
565+
enum_vals_str=enum_vals_str
566+
)
563567
)
564568

565569
if enum_regexs:
@@ -576,7 +580,9 @@ def description(self):
576580
desc
577581
+ """
578582
- A string that matches one of the following regular expressions:
579-
{enum_regexs_str}""".format(enum_regexs_str=enum_regexs_str)
583+
{enum_regexs_str}""".format(
584+
enum_regexs_str=enum_regexs_str
585+
)
580586
)
581587

582588
if self.array_ok:
@@ -647,7 +653,9 @@ def __init__(self, plotly_name, parent_name, array_ok=False, **kwargs):
647653
def description(self):
648654
desc = """\
649655
The '{plotly_name}' property is a boolean and must be specified as:
650-
- A boolean value: True or False""".format(plotly_name=self.plotly_name)
656+
- A boolean value: True or False""".format(
657+
plotly_name=self.plotly_name
658+
)
651659
if self.array_ok:
652660
desc += """
653661
- A tuple or list of the above"""
@@ -678,7 +686,9 @@ def __init__(self, plotly_name, parent_name, **kwargs):
678686
def description(self):
679687
return """\
680688
The '{plotly_name}' property must be specified as a string or
681-
as a plotly.grid_objs.Column object""".format(plotly_name=self.plotly_name)
689+
as a plotly.grid_objs.Column object""".format(
690+
plotly_name=self.plotly_name
691+
)
682692

683693
def validate_coerce(self, v):
684694
if is_none_or_typed_array_spec(v):
@@ -899,10 +909,13 @@ def description(self):
899909

900910
# Extras
901911
if self.extras:
902-
desc = desc + (
903-
"""
912+
desc = (
913+
desc
914+
+ (
915+
"""
904916
OR exactly one of {extras} (e.g. '{eg_extra}')"""
905-
).format(extras=self.extras, eg_extra=self.extras[-1])
917+
).format(extras=self.extras, eg_extra=self.extras[-1])
918+
)
906919

907920
if self.array_ok:
908921
desc = (
@@ -1049,7 +1062,9 @@ def description(self):
10491062
desc
10501063
+ """
10511064
- One of the following strings:
1052-
{valid_str}""".format(valid_str=valid_str)
1065+
{valid_str}""".format(
1066+
valid_str=valid_str
1067+
)
10531068
)
10541069
else:
10551070
desc = (
@@ -1349,7 +1364,9 @@ def description(self):
13491364
valid_color_description
13501365
+ """
13511366
- A number that will be interpreted as a color
1352-
according to {colorscale_path}""".format(colorscale_path=self.colorscale_path)
1367+
according to {colorscale_path}""".format(
1368+
colorscale_path=self.colorscale_path
1369+
)
13531370
)
13541371

13551372
if self.array_ok:
@@ -1500,7 +1517,9 @@ def description(self):
15001517
return """\
15011518
The '{plotly_name}' property is a colorlist that may be specified
15021519
as a tuple, list, one-dimensional numpy array, or pandas Series of valid
1503-
color strings""".format(plotly_name=self.plotly_name)
1520+
color strings""".format(
1521+
plotly_name=self.plotly_name
1522+
)
15041523

15051524
def validate_coerce(self, v):
15061525
if is_none_or_typed_array_spec(v):
@@ -1598,7 +1617,9 @@ def description(self):
15981617
- One of the following named colorscales:
15991618
{colorscales_str}.
16001619
Appending '_r' to a named colorscale reverses it.
1601-
""".format(plotly_name=self.plotly_name, colorscales_str=colorscales_str)
1620+
""".format(
1621+
plotly_name=self.plotly_name, colorscales_str=colorscales_str
1622+
)
16021623

16031624
return desc
16041625

@@ -1857,18 +1878,24 @@ def description(self):
18571878
).format(plotly_name=self.plotly_name)
18581879

18591880
# Flags
1860-
desc = desc + (
1861-
"""
1881+
desc = (
1882+
desc
1883+
+ (
1884+
"""
18621885
- Any combination of {flags} joined with '+' characters
18631886
(e.g. '{eg_flag}')"""
1864-
).format(flags=self.flags, eg_flag="+".join(self.flags[:2]))
1887+
).format(flags=self.flags, eg_flag="+".join(self.flags[:2]))
1888+
)
18651889

18661890
# Extras
18671891
if self.extras:
1868-
desc = desc + (
1869-
"""
1892+
desc = (
1893+
desc
1894+
+ (
1895+
"""
18701896
OR exactly one of {extras} (e.g. '{eg_extra}')"""
1871-
).format(extras=self.extras, eg_extra=self.extras[-1])
1897+
).format(extras=self.extras, eg_extra=self.extras[-1])
1898+
)
18721899

18731900
if self.array_ok:
18741901
desc = (
@@ -1949,7 +1976,9 @@ def __init__(self, plotly_name, parent_name, values=None, array_ok=False, **kwar
19491976
def description(self):
19501977
desc = """\
19511978
The '{plotly_name}' property accepts values of any type
1952-
""".format(plotly_name=self.plotly_name)
1979+
""".format(
1980+
plotly_name=self.plotly_name
1981+
)
19531982
return desc
19541983

19551984
def validate_coerce(self, v):
@@ -2020,7 +2049,9 @@ def description(self):
20202049
#
20212050
desc = """\
20222051
The '{plotly_name}' property is an info array that may be specified as:\
2023-
""".format(plotly_name=self.plotly_name)
2052+
""".format(
2053+
plotly_name=self.plotly_name
2054+
)
20242055

20252056
if isinstance(self.items, list):
20262057
# ### Case 1 ###
@@ -2029,14 +2060,18 @@ def description(self):
20292060
desc += """
20302061
20312062
* a list or tuple of{upto} {N} elements where:\
2032-
""".format(upto=upto, N=len(self.item_validators))
2063+
""".format(
2064+
upto=upto, N=len(self.item_validators)
2065+
)
20332066

20342067
for i, item_validator in enumerate(self.item_validators):
20352068
el_desc = item_validator.description().strip()
20362069
desc = (
20372070
desc
20382071
+ """
2039-
({i}) {el_desc}""".format(i=i, el_desc=el_desc)
2072+
({i}) {el_desc}""".format(
2073+
i=i, el_desc=el_desc
2074+
)
20402075
)
20412076

20422077
# ### Case 2 ###
@@ -2057,7 +2092,9 @@ def description(self):
20572092
desc = (
20582093
desc
20592094
+ """
2060-
({i}) {el_desc}""".format(i=i, el_desc=el_desc)
2095+
({i}) {el_desc}""".format(
2096+
i=i, el_desc=el_desc
2097+
)
20612098
)
20622099
item_validator.plotly_name = orig_name
20632100
else:
@@ -2074,7 +2111,9 @@ def description(self):
20742111
desc += """
20752112
* a list of elements where:
20762113
{el_desc}
2077-
""".format(el_desc=el_desc)
2114+
""".format(
2115+
el_desc=el_desc
2116+
)
20782117

20792118
if self.dimensions in ("1-2", 2):
20802119
item_validator.plotly_name = "{name}[i][j]".format(
@@ -2085,7 +2124,9 @@ def description(self):
20852124
desc += """
20862125
* a 2D list where:
20872126
{el_desc}
2088-
""".format(el_desc=el_desc)
2127+
""".format(
2128+
el_desc=el_desc
2129+
)
20892130

20902131
item_validator.plotly_name = orig_name
20912132

@@ -2327,7 +2368,9 @@ def description(self):
23272368
desc
23282369
+ """
23292370
- One of the following dash styles:
2330-
{enum_vals_str}""".format(enum_vals_str=enum_vals_str)
2371+
{enum_vals_str}""".format(
2372+
enum_vals_str=enum_vals_str
2373+
)
23312374
)
23322375

23332376
desc = (
@@ -2363,7 +2406,9 @@ def description(self):
23632406
- A PIL.Image.Image object which will be immediately converted
23642407
to a data URI image string
23652408
See http://pillow.readthedocs.io/en/latest/reference/Image.html
2366-
""".format(plotly_name=self.plotly_name)
2409+
""".format(
2410+
plotly_name=self.plotly_name
2411+
)
23672412
return desc
23682413

23692414
def validate_coerce(self, v):

codegen/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,7 @@ def name_property(self):
377377

378378
return self.plotly_name + (
379379
"s"
380-
if self.is_array_element
381-
and
380+
if self.is_array_element and
382381
# Don't add 's' to layout.template.data.scatter etc.
383382
not (
384383
self.parent

commands.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ def overwrite_plotlyjs_version_file(plotlyjs_version):
143143
# DO NOT EDIT
144144
# This file is generated by the updatebundle commands.py command
145145
__plotlyjs_version__ = "{plotlyjs_version}"
146-
""".format(plotlyjs_version=plotlyjs_version)
146+
""".format(
147+
plotlyjs_version=plotlyjs_version
148+
)
147149
)
148150

149151

plotly/_subplots.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,15 +360,19 @@ def make_subplots(
360360
raise ValueError(
361361
"""
362362
The 'rows' argument to make_subplots must be an int greater than 0.
363-
Received value of type {typ}: {val}""".format(typ=type(rows), val=repr(rows))
363+
Received value of type {typ}: {val}""".format(
364+
typ=type(rows), val=repr(rows)
365+
)
364366
)
365367

366368
# ### cols ###
367369
if not isinstance(cols, int) or cols <= 0:
368370
raise ValueError(
369371
"""
370372
The 'cols' argument to make_subplots must be an int greater than 0.
371-
Received value of type {typ}: {val}""".format(typ=type(cols), val=repr(cols))
373+
Received value of type {typ}: {val}""".format(
374+
typ=type(cols), val=repr(cols)
375+
)
372376
)
373377

374378
# ### start_cell ###
@@ -468,7 +472,9 @@ def _checks(item, defaults):
468472
"""
469473
The 'secondary_y' spec property is not supported for subplot of type '{s_typ}'
470474
'secondary_y' is only supported for subplots of type 'xy'
471-
""".format(s_typ=spec["type"])
475+
""".format(
476+
s_typ=spec["type"]
477+
)
472478
)
473479

474480
# ### insets ###
@@ -480,7 +486,9 @@ def _checks(item, defaults):
480486
raise ValueError(
481487
"""
482488
The 'insets' argument to make_subplots must be a list of dictionaries.
483-
Received value of type {typ}: {val}""".format(typ=type(insets), val=repr(insets))
489+
Received value of type {typ}: {val}""".format(
490+
typ=type(insets), val=repr(insets)
491+
)
484492
)
485493

486494
if insets:
@@ -1408,7 +1416,9 @@ def _set_trace_grid_reference(trace, layout, grid_ref, row, col, secondary_y=Fal
14081416
if not subplot_refs:
14091417
raise ValueError(
14101418
"""
1411-
No subplot specified at grid position ({row}, {col})""".format(row=row, col=col)
1419+
No subplot specified at grid position ({row}, {col})""".format(
1420+
row=row, col=col
1421+
)
14121422
)
14131423

14141424
if secondary_y:
@@ -1500,7 +1510,9 @@ def _get_grid_subplot(fig, row, col, secondary_y=False):
15001510
else:
15011511
raise ValueError(
15021512
"""
1503-
Unexpected subplot type with layout_keys of {}""".format(layout_keys)
1513+
Unexpected subplot type with layout_keys of {}""".format(
1514+
layout_keys
1515+
)
15041516
)
15051517

15061518

plotly/basedatatypes.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,9 @@ def _perform_plotly_restyle(self, restyle_data, trace_indexes):
17571757
raise ValueError(
17581758
"""
17591759
Invalid property path '{key_path_str}' for trace class {trace_class}
1760-
""".format(key_path_str=key_path_str, trace_class=trace_class)
1760+
""".format(
1761+
key_path_str=key_path_str, trace_class=trace_class
1762+
)
17611763
)
17621764

17631765
# Apply set operation for this trace and thist value
@@ -2002,7 +2004,9 @@ def _raise_invalid_rows_cols(name, n, invalid):
20022004
of length {n} (The number of traces being added)
20032005
20042006
Received: {invalid}
2005-
""".format(name=name, n=n, invalid=invalid)
2007+
""".format(
2008+
name=name, n=n, invalid=invalid
2009+
)
20062010

20072011
raise ValueError(rows_err_msg)
20082012

@@ -2658,7 +2662,9 @@ def _perform_plotly_relayout(self, relayout_data):
26582662
raise ValueError(
26592663
"""
26602664
Invalid property path '{key_path_str}' for layout
2661-
""".format(key_path_str=key_path_str)
2665+
""".format(
2666+
key_path_str=key_path_str
2667+
)
26622668
)
26632669

26642670
# Apply set operation on the layout dict
@@ -5616,7 +5622,9 @@ def on_change(self, callback, *args, **kwargs):
56165622
msg = """
56175623
{class_name} object is not a descendant of a Figure.
56185624
on_change callbacks are not supported in this case.
5619-
""".format(class_name=class_name)
5625+
""".format(
5626+
class_name=class_name
5627+
)
56205628
raise ValueError(msg)
56215629

56225630
# Validate args not empty

plotly/callbacks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ def __init__(self, xrange=None, yrange=None, **_):
208208
def __repr__(self):
209209
return """\
210210
BoxSelector(xrange={xrange},
211-
yrange={yrange})""".format(xrange=self.xrange, yrange=self.yrange)
211+
yrange={yrange})""".format(
212+
xrange=self.xrange, yrange=self.yrange
213+
)
212214

213215
@property
214216
def type(self):

0 commit comments

Comments
 (0)