13
13
parameter set listed here should also be visited to the
14
14
:file:`matplotlibrc.template` in matplotlib's root source directory.
15
15
"""
16
- from __future__ import (absolute_import , division , print_function ,
17
- unicode_literals )
16
+ from __future__ import absolute_import , division , print_function
18
17
19
18
import six
20
19
@@ -97,11 +96,10 @@ def f(s):
97
96
else :
98
97
raise ValueError ("{!r} must be of type: string or non-dictionary "
99
98
"iterable" .format (s ))
100
- # Cast `str` to keep Py2 happy despite `unicode_literals`.
101
99
try :
102
- f .__name__ = str ( "{}list" .format (scalar_validator .__name__ ) )
100
+ f .__name__ = "{}list" .format (scalar_validator .__name__ )
103
101
except AttributeError : # class instance.
104
- f .__name__ = str ( "{}List" .format (type (scalar_validator ).__name__ ) )
102
+ f .__name__ = "{}List" .format (type (scalar_validator ).__name__ )
105
103
f .__doc__ = scalar_validator .__doc__
106
104
return f
107
105
@@ -185,7 +183,7 @@ def validate_string_or_None(s):
185
183
if s is None :
186
184
return None
187
185
try :
188
- return six . text_type (s )
186
+ return validate_string (s )
189
187
except ValueError :
190
188
raise ValueError ('Could not convert "%s" to string' % s )
191
189
@@ -409,7 +407,15 @@ def deprecate_axes_colorcycle(value):
409
407
validate_colorlist = _listify_validator (validate_color , allow_stringlist = True )
410
408
validate_colorlist .__doc__ = 'return a list of colorspecs'
411
409
412
- validate_stringlist = _listify_validator (six .text_type )
410
+ def validate_string (s ):
411
+ if isinstance (s , str ): # Always leave str as str
412
+ return s
413
+ elif isinstance (s , six .text_type ):
414
+ return s
415
+ else :
416
+ return str (s )
417
+
418
+ validate_stringlist = _listify_validator (str )
413
419
validate_stringlist .__doc__ = 'return a list'
414
420
415
421
validate_orientation = ValidateInStrings (
@@ -483,7 +489,7 @@ def validate_whiskers(s):
483
489
def update_savefig_format (value ):
484
490
# The old savefig.extension could also have a value of "auto", but
485
491
# the new savefig.format does not. We need to fix this here.
486
- value = six . text_type (value )
492
+ value = validate_string (value )
487
493
if value == 'auto' :
488
494
value = 'png'
489
495
return value
@@ -962,17 +968,17 @@ def _validate_linestyle(ls):
962
968
'datapath' : [None , validate_path_exists ], # handled by
963
969
# _get_data_path_cached
964
970
'interactive' : [False , validate_bool ],
965
- 'timezone' : ['UTC' , six . text_type ],
971
+ 'timezone' : ['UTC' , validate_string ],
966
972
967
973
# the verbosity setting
968
974
'verbose.level' : ['silent' , validate_verbose ],
969
- 'verbose.fileo' : ['sys.stdout' , six . text_type ],
975
+ 'verbose.fileo' : ['sys.stdout' , validate_string ],
970
976
971
977
# line props
972
978
'lines.linewidth' : [1.5 , validate_float ], # line width in points
973
979
'lines.linestyle' : ['-' , _validate_linestyle ], # solid line
974
980
'lines.color' : ['C0' , validate_color ], # first color in color cycle
975
- 'lines.marker' : ['None' , six . text_type ], # marker name
981
+ 'lines.marker' : ['None' , validate_string ], # marker name
976
982
'lines.markeredgewidth' : [1.0 , validate_float ],
977
983
'lines.markersize' : [6 , validate_float ], # markersize, in points
978
984
'lines.antialiased' : [True , validate_bool ], # antialiased (no jaggies)
@@ -1016,7 +1022,7 @@ def _validate_linestyle(ls):
1016
1022
'boxplot.meanline' : [False , validate_bool ],
1017
1023
1018
1024
'boxplot.flierprops.color' : ['k' , validate_color ],
1019
- 'boxplot.flierprops.marker' : ['o' , six . text_type ],
1025
+ 'boxplot.flierprops.marker' : ['o' , validate_string ],
1020
1026
'boxplot.flierprops.markerfacecolor' : ['none' , validate_color_or_auto ],
1021
1027
'boxplot.flierprops.markeredgecolor' : ['k' , validate_color ],
1022
1028
'boxplot.flierprops.markersize' : [6 , validate_float ],
@@ -1040,7 +1046,7 @@ def _validate_linestyle(ls):
1040
1046
'boxplot.medianprops.linestyle' : ['-' , _validate_linestyle ],
1041
1047
1042
1048
'boxplot.meanprops.color' : ['C2' , validate_color ],
1043
- 'boxplot.meanprops.marker' : ['^' , six . text_type ],
1049
+ 'boxplot.meanprops.marker' : ['^' , validate_string ],
1044
1050
'boxplot.meanprops.markerfacecolor' : ['C2' , validate_color ],
1045
1051
'boxplot.meanprops.markeredgecolor' : ['C2' , validate_color ],
1046
1052
'boxplot.meanprops.markersize' : [6 , validate_float ],
@@ -1049,10 +1055,10 @@ def _validate_linestyle(ls):
1049
1055
1050
1056
## font props
1051
1057
'font.family' : [['sans-serif' ], validate_stringlist ], # used by text object
1052
- 'font.style' : ['normal' , six . text_type ],
1053
- 'font.variant' : ['normal' , six . text_type ],
1054
- 'font.stretch' : ['normal' , six . text_type ],
1055
- 'font.weight' : ['normal' , six . text_type ],
1058
+ 'font.style' : ['normal' , validate_string ],
1059
+ 'font.variant' : ['normal' , validate_string ],
1060
+ 'font.stretch' : ['normal' , validate_string ],
1061
+ 'font.weight' : ['normal' , validate_string ],
1056
1062
'font.size' : [10 , validate_float ], # Base font size in points
1057
1063
'font.serif' : [['DejaVu Serif' , 'Bitstream Vera Serif' ,
1058
1064
'Computer Modern Roman' ,
@@ -1100,10 +1106,10 @@ def _validate_linestyle(ls):
1100
1106
'mathtext.fallback_to_cm' : [True , validate_bool ],
1101
1107
1102
1108
'image.aspect' : ['equal' , validate_aspect ], # equal, auto, a number
1103
- 'image.interpolation' : ['nearest' , six . text_type ],
1104
- 'image.cmap' : ['viridis' , six . text_type ], # one of gray, jet, etc
1109
+ 'image.interpolation' : ['nearest' , validate_string ],
1110
+ 'image.cmap' : ['viridis' , validate_string ], # one of gray, jet, etc
1105
1111
'image.lut' : [256 , validate_int ], # lookup table
1106
- 'image.origin' : ['upper' , six . text_type ], # lookup table
1112
+ 'image.origin' : ['upper' , validate_string ], # lookup table
1107
1113
'image.resample' : [True , validate_bool ],
1108
1114
# Specify whether vector graphics backends will combine all images on a
1109
1115
# set of axes into a single composite image
@@ -1130,7 +1136,7 @@ def _validate_linestyle(ls):
1130
1136
1131
1137
'axes.titlesize' : ['large' , validate_fontsize ], # fontsize of the
1132
1138
# axes title
1133
- 'axes.titleweight' : ['normal' , six . text_type ], # font weight of axes title
1139
+ 'axes.titleweight' : ['normal' , validate_string ], # font weight of axes title
1134
1140
'axes.titlepad' : [6.0 , validate_float ], # pad from axes top to title in points
1135
1141
'axes.grid' : [False , validate_bool ], # display grid or not
1136
1142
'axes.grid.which' : ['major' , validate_axis_locator ], # set wether the gid are by
@@ -1142,7 +1148,7 @@ def _validate_linestyle(ls):
1142
1148
'axes.labelsize' : ['medium' , validate_fontsize ], # fontsize of the
1143
1149
# x any y labels
1144
1150
'axes.labelpad' : [4.0 , validate_float ], # space between label and axis
1145
- 'axes.labelweight' : ['normal' , six . text_type ], # fontsize of the x any y labels
1151
+ 'axes.labelweight' : ['normal' , validate_string ], # fontsize of the x any y labels
1146
1152
'axes.labelcolor' : ['k' , validate_color ], # color of axis label
1147
1153
'axes.formatter.limits' : [[- 7 , 7 ], validate_nseq_int (2 )],
1148
1154
# use scientific notation if log10
@@ -1187,16 +1193,16 @@ def _validate_linestyle(ls):
1187
1193
'axes3d.grid' : [True , validate_bool ], # display 3d grid
1188
1194
1189
1195
# scatter props
1190
- 'scatter.marker' : ['o' , six . text_type ],
1196
+ 'scatter.marker' : ['o' , validate_string ],
1191
1197
1192
1198
# TODO validate that these are valid datetime format strings
1193
- 'date.autoformatter.year' : ['%Y' , six . text_type ],
1194
- 'date.autoformatter.month' : ['%Y-%m' , six . text_type ],
1195
- 'date.autoformatter.day' : ['%Y-%m-%d' , six . text_type ],
1196
- 'date.autoformatter.hour' : ['%m-%d %H' , six . text_type ],
1197
- 'date.autoformatter.minute' : ['%d %H:%M' , six . text_type ],
1198
- 'date.autoformatter.second' : ['%H:%M:%S' , six . text_type ],
1199
- 'date.autoformatter.microsecond' : ['%M:%S.%f' , six . text_type ],
1199
+ 'date.autoformatter.year' : ['%Y' , validate_string ],
1200
+ 'date.autoformatter.month' : ['%Y-%m' , validate_string ],
1201
+ 'date.autoformatter.day' : ['%Y-%m-%d' , validate_string ],
1202
+ 'date.autoformatter.hour' : ['%m-%d %H' , validate_string ],
1203
+ 'date.autoformatter.minute' : ['%d %H:%M' , validate_string ],
1204
+ 'date.autoformatter.second' : ['%H:%M:%S' , validate_string ],
1205
+ 'date.autoformatter.microsecond' : ['%M:%S.%f' , validate_string ],
1200
1206
1201
1207
#legend properties
1202
1208
'legend.fancybox' : [True , validate_bool ],
@@ -1249,7 +1255,7 @@ def _validate_linestyle(ls):
1249
1255
1250
1256
# fontsize of the xtick labels
1251
1257
'xtick.labelsize' : ['medium' , validate_fontsize ],
1252
- 'xtick.direction' : ['out' , six . text_type ], # direction of xticks
1258
+ 'xtick.direction' : ['out' , validate_string ], # direction of xticks
1253
1259
'xtick.alignment' : ["center" , _validate_alignment ],
1254
1260
1255
1261
'ytick.left' : [True , validate_bool ], # draw ticks on the left side
@@ -1269,7 +1275,7 @@ def _validate_linestyle(ls):
1269
1275
1270
1276
# fontsize of the ytick labels
1271
1277
'ytick.labelsize' : ['medium' , validate_fontsize ],
1272
- 'ytick.direction' : ['out' , six . text_type ], # direction of yticks
1278
+ 'ytick.direction' : ['out' , validate_string ], # direction of yticks
1273
1279
'ytick.alignment' : ["center_baseline" , _validate_alignment ],
1274
1280
1275
1281
@@ -1282,7 +1288,7 @@ def _validate_linestyle(ls):
1282
1288
## figure props
1283
1289
# figure title
1284
1290
'figure.titlesize' : ['large' , validate_fontsize ],
1285
- 'figure.titleweight' : ['normal' , six . text_type ],
1291
+ 'figure.titleweight' : ['normal' , validate_string ],
1286
1292
1287
1293
# figure size in inches: width by height
1288
1294
'figure.figsize' : [[6.4 , 4.8 ], validate_nseq_float (2 )],
@@ -1320,7 +1326,7 @@ def _validate_linestyle(ls):
1320
1326
'savefig.bbox' : ['standard' , validate_bbox ],
1321
1327
'savefig.pad_inches' : [0.1 , validate_float ],
1322
1328
# default directory in savefig dialog box
1323
- 'savefig.directory' : ['~' , six . text_type ],
1329
+ 'savefig.directory' : ['~' , validate_string ],
1324
1330
'savefig.transparent' : [False , validate_bool ],
1325
1331
1326
1332
# Maintain shell focus for TkAgg
@@ -1361,7 +1367,7 @@ def _validate_linestyle(ls):
1361
1367
# set this when you want to generate hardcopy docstring
1362
1368
'docstring.hardcopy' : [False , validate_bool ],
1363
1369
# where plugin directory is locate
1364
- 'plugins.directory' : ['.matplotlib_plugins' , six . text_type ],
1370
+ 'plugins.directory' : ['.matplotlib_plugins' , validate_string ],
1365
1371
1366
1372
'path.simplify' : [True , validate_bool ],
1367
1373
'path.simplify_threshold' : [1.0 / 9.0 , ValidateInterval (0.0 , 1.0 )],
@@ -1387,15 +1393,15 @@ def _validate_linestyle(ls):
1387
1393
'keymap.all_axes' : [['a' ], validate_stringlist ],
1388
1394
1389
1395
# sample data
1390
- 'examples.directory' : ['' , six . text_type ],
1396
+ 'examples.directory' : ['' , validate_string ],
1391
1397
1392
1398
# Animation settings
1393
1399
'animation.html' : ['none' , validate_movie_html_fmt ],
1394
1400
# Limit, in MB, of size of base64 encoded animation in HTML
1395
1401
# (i.e. IPython notebook)
1396
1402
'animation.embed_limit' : [20 , validate_float ],
1397
1403
'animation.writer' : ['ffmpeg' , validate_movie_writer ],
1398
- 'animation.codec' : ['h264' , six . text_type ],
1404
+ 'animation.codec' : ['h264' , validate_string ],
1399
1405
'animation.bitrate' : [- 1 , validate_int ],
1400
1406
# Controls image format when frames are written to disk
1401
1407
'animation.frame_format' : ['png' , validate_movie_frame_fmt ],
0 commit comments