pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/plotly/plotly.py/commit/e9b3f57bd1ffd228b02103833a3ca054206c4446

nk crossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-9c8f61f9f58ad7b2.css" /> matplotlib 2.2.2 - convert unicode to btyte str for matplotlib renderer · plotly/plotly.py@e9b3f57 · GitHub
Skip to content

Commit e9b3f57

Browse files
committed
matplotlib 2.2.2 - convert unicode to btyte str for matplotlib renderer
1 parent 002225a commit e9b3f57

4 files changed

Lines changed: 28 additions & 17 deletions

File tree

_plotly_utils/basevalidators.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def __init__(self,
349349
# ----------------------------
350350
# Look for regular expressions
351351
for v in self.values:
352-
if v and isinstance(v, six.string_types) and v[0] == '/' and v[-1] == '/':
352+
if v and isinstance(v, str) and v[0] == '/' and v[-1] == '/':
353353
# String is a regex with leading and trailing '/' character
354354
regex_str = v[1:-1]
355355
self.val_regexs.append(re.compile(regex_str))
@@ -387,7 +387,7 @@ def perform_replacemenet(self, v):
387387
"""
388388
Return v with any applicable regex replacements applied
389389
"""
390-
if isinstance(v, six.string_types):
390+
if isinstance(v, str):
391391
for repl_args in self.regex_replacements:
392392
if repl_args:
393393
v = re.sub(repl_args[0], repl_args[1], v)
@@ -442,7 +442,7 @@ def in_values(self, e):
442442
"""
443443
Return whether a value matches one of the enumeration options
444444
"""
445-
is_str = isinstance(e, six.string_types)
445+
is_str = isinstance(e, str)
446446
for v, regex in zip(self.values, self.val_regexs):
447447
if is_str and regex:
448448
in_values = fullmatch(regex, e) is not None
@@ -821,7 +821,7 @@ def validate_coerce(self, v):
821821

822822
# If strict, make sure all elements are strings.
823823
if self.strict:
824-
invalid_els = [e for e in v if not isinstance(e, six.string_types)]
824+
invalid_els = [e for e in v if not isinstance(e, str)]
825825
if invalid_els:
826826
self.raise_invalid_elements(invalid_els)
827827

@@ -862,10 +862,10 @@ def validate_coerce(self, v):
862862

863863
else:
864864
if self.strict:
865-
if not isinstance(v, six.string_types):
865+
if not isinstance(v, str):
866866
self.raise_invalid_val(v)
867867
else:
868-
if not isinstance(v, (six.string_types, int, float)):
868+
if not isinstance(v, (str, int, float)):
869869
self.raise_invalid_val(v)
870870

871871
# Convert value to a string
@@ -1061,7 +1061,7 @@ def perform_validate_coerce(v, allow_number=None):
10611061
if isinstance(v, numbers.Number) and allow_number:
10621062
# If allow_numbers then any number is ok
10631063
return v
1064-
elif not isinstance(v, six.string_types):
1064+
elif not isinstance(v, str):
10651065
# If not allow_numbers then value must be a string
10661066
return None
10671067
else:
@@ -1183,7 +1183,7 @@ def validate_coerce(self, v):
11831183
pass
11841184
if v is None:
11851185
v_valid = True
1186-
elif isinstance(v, six.string_types):
1186+
elif isinstance(v, str):
11871187
v_match = [
11881188
el for el in ColorscaleValidator.named_colorscales
11891189
if el.lower() == v.lower()
@@ -1198,7 +1198,7 @@ def validate_coerce(self, v):
11981198
len(e) != 2 or
11991199
not isinstance(e[0], numbers.Number) or
12001200
not (0 <= e[0] <= 1) or
1201-
not isinstance(e[1], six.string_types) or
1201+
not isinstance(e[1], str) or
12021202
ColorValidator.perform_validate_coerce(e[1]) is None)]
12031203

12041204
if len(invalid_els) == 0:
@@ -1294,7 +1294,7 @@ def description(self):
12941294
def validate_coerce(self, v):
12951295
if v is None:
12961296
pass
1297-
elif not isinstance(v, six.string_types):
1297+
elif not isinstance(v, str):
12981298
self.raise_invalid_val(v)
12991299
else:
13001300
# match = re.fullmatch(self.regex, v)
@@ -1376,7 +1376,7 @@ def description(self):
13761376
return desc
13771377

13781378
def vc_scalar(self, v):
1379-
if not isinstance(v, six.string_types):
1379+
if not isinstance(v, str):
13801380
return None
13811381

13821382
# To be generous we accept flags separated on plus ('+'),
@@ -1617,7 +1617,7 @@ def description(self):
16171617
def validate_coerce(self, v):
16181618
if v is None:
16191619
pass
1620-
elif isinstance(v, six.string_types):
1620+
elif isinstance(v, str):
16211621
# Future possibilities:
16221622
# - Detect filesystem system paths and convert to URI
16231623
# - Validate either url or data uri

optional-requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
## numpy (technically, this is covered by matplotlib's deps) ##
99
numpy
1010

11-
## matplotlylib dependencies ##
12-
# matplotlib==1.3.1
11+
## matplotlylib dependencies - moving away from 1.3.1 ##
12+
# matplotlib==2.2.2
1313

1414
## testing dependencies ##
1515
coverage==4.3.1

plotly/matplotlylib/renderer.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99
from __future__ import absolute_import
1010

11+
import six
1112
import warnings
1213

1314
import plotly.graph_objs as go
@@ -364,7 +365,9 @@ def draw_marked_line(self, **props):
364365
if props['coordinates'] == 'data':
365366
marked_line = go.Scatter(
366367
mode=mode,
367-
name=props['label'],
368+
name=(str(props['label']) if
369+
isinstance(props['label'], six.string_types) else
370+
props['label']),
368371
x=[xy_pair[0] for xy_pair in props['data']],
369372
y=[xy_pair[1] for xy_pair in props['data']],
370373
xaxis='x{0}'.format(self.axis_ct),
@@ -572,7 +575,9 @@ def draw_text(self, **props):
572575
xanchor = props['style']['halign'] # no difference here!
573576
yanchor = mpltools.convert_va(props['style']['valign'])
574577
annotation = go.Annotation(
575-
text=props['text'],
578+
text=(str(props['text']) if
579+
isinstance(props['text'], six.string_types) else
580+
props['text']),
576581
opacity=props['style']['alpha'],
577582
x=x,
578583
y=y,
@@ -674,7 +679,7 @@ def draw_xlabel(self, **props):
674679
"""
675680
self.msg += " Adding xlabel\n"
676681
axis_key = 'xaxis{0}'.format(self.axis_ct)
677-
self.plotly_fig['layout'][axis_key]['title'] = props['text']
682+
self.plotly_fig['layout'][axis_key]['title'] = str(props['text'])
678683
titlefont = go.Font(
679684
size=props['style']['fontsize'],
680685
color=props['style']['color'])

plotly/tests/test_optional/test_matplotlylib/test_scatter.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ def test_simple_scatter():
2424
renderer = run_fig(fig)
2525
for data_no, data_dict in enumerate(renderer.plotly_fig['data']):
2626
d1, d2 = strip_dict_params(data_dict, SIMPLE_SCATTER['data'][data_no], ignore=['uid'])
27+
print(d1)
28+
print('\n')
29+
print(d2)
2730
assert d1 == d2
2831

2932
equivalent, msg = compare_dict(renderer.plotly_fig['layout'],
@@ -39,6 +42,9 @@ def test_double_scatter():
3942
renderer = run_fig(fig)
4043
for data_no, data_dict in enumerate(renderer.plotly_fig['data']):
4144
d1, d2 = strip_dict_params(data_dict, DOUBLE_SCATTER['data'][data_no], ignore=['uid'])
45+
print(d1)
46+
print('\n')
47+
print(d2)
4248
assert d1 == d2
4349

4450
equivalent, msg = compare_dict(renderer.plotly_fig['layout'],

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy