1313parameter set listed here should also be visited to the
1414:file:`matplotlibrc.template` in matplotlib's root source directory.
1515"""
16- from __future__ import (absolute_import , division , print_function ,
17- unicode_literals )
16+ from __future__ import absolute_import , division , print_function
1817
1918import six
2019
@@ -97,11 +96,10 @@ def f(s):
9796 else :
9897 raise ValueError ("{!r} must be of type: string or non-dictionary "
9998 "iterable" .format (s ))
100- # Cast `str` to keep Py2 happy despite `unicode_literals`.
10199 try :
102- f .__name__ = str ( "{}list" .format (scalar_validator .__name__ ) )
100+ f .__name__ = "{}list" .format (scalar_validator .__name__ )
103101 except AttributeError : # class instance.
104- f .__name__ = str ( "{}List" .format (type (scalar_validator ).__name__ ) )
102+ f .__name__ = "{}List" .format (type (scalar_validator ).__name__ )
105103 f .__doc__ = scalar_validator .__doc__
106104 return f
107105
@@ -185,7 +183,7 @@ def validate_string_or_None(s):
185183 if s is None :
186184 return None
187185 try :
188- return six . text_type (s )
186+ return validate_string (s )
189187 except ValueError :
190188 raise ValueError ('Could not convert "%s" to string' % s )
191189
@@ -409,7 +407,15 @@ def deprecate_axes_colorcycle(value):
409407validate_colorlist = _listify_validator (validate_color , allow_stringlist = True )
410408validate_colorlist .__doc__ = 'return a list of colorspecs'
411409
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 )
413419validate_stringlist .__doc__ = 'return a list'
414420
415421validate_orientation = ValidateInStrings (
@@ -483,7 +489,7 @@ def validate_whiskers(s):
483489def update_savefig_format (value ):
484490 # The old savefig.extension could also have a value of "auto", but
485491 # the new savefig.format does not. We need to fix this here.
486- value = six . text_type (value )
492+ value = validate_string (value )
487493 if value == 'auto' :
488494 value = 'png'
489495 return value
@@ -962,17 +968,17 @@ def _validate_linestyle(ls):
962968 'datapath' : [None , validate_path_exists ], # handled by
963969 # _get_data_path_cached
964970 'interactive' : [False , validate_bool ],
965- 'timezone' : ['UTC' , six . text_type ],
971+ 'timezone' : ['UTC' , validate_string ],
966972
967973 # the verbosity setting
968974 'verbose.level' : ['silent' , validate_verbose ],
969- 'verbose.fileo' : ['sys.stdout' , six . text_type ],
975+ 'verbose.fileo' : ['sys.stdout' , validate_string ],
970976
971977 # line props
972978 'lines.linewidth' : [1.5 , validate_float ], # line width in points
973979 'lines.linestyle' : ['-' , _validate_linestyle ], # solid line
974980 '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
976982 'lines.markeredgewidth' : [1.0 , validate_float ],
977983 'lines.markersize' : [6 , validate_float ], # markersize, in points
978984 'lines.antialiased' : [True , validate_bool ], # antialiased (no jaggies)
@@ -1016,7 +1022,7 @@ def _validate_linestyle(ls):
10161022 'boxplot.meanline' : [False , validate_bool ],
10171023
10181024 'boxplot.flierprops.color' : ['k' , validate_color ],
1019- 'boxplot.flierprops.marker' : ['o' , six . text_type ],
1025+ 'boxplot.flierprops.marker' : ['o' , validate_string ],
10201026 'boxplot.flierprops.markerfacecolor' : ['none' , validate_color_or_auto ],
10211027 'boxplot.flierprops.markeredgecolor' : ['k' , validate_color ],
10221028 'boxplot.flierprops.markersize' : [6 , validate_float ],
@@ -1040,7 +1046,7 @@ def _validate_linestyle(ls):
10401046 'boxplot.medianprops.linestyle' : ['-' , _validate_linestyle ],
10411047
10421048 'boxplot.meanprops.color' : ['C2' , validate_color ],
1043- 'boxplot.meanprops.marker' : ['^' , six . text_type ],
1049+ 'boxplot.meanprops.marker' : ['^' , validate_string ],
10441050 'boxplot.meanprops.markerfacecolor' : ['C2' , validate_color ],
10451051 'boxplot.meanprops.markeredgecolor' : ['C2' , validate_color ],
10461052 'boxplot.meanprops.markersize' : [6 , validate_float ],
@@ -1049,10 +1055,10 @@ def _validate_linestyle(ls):
10491055
10501056 ## font props
10511057 '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 ],
10561062 'font.size' : [10 , validate_float ], # Base font size in points
10571063 'font.serif' : [['DejaVu Serif' , 'Bitstream Vera Serif' ,
10581064 'Computer Modern Roman' ,
@@ -1100,10 +1106,10 @@ def _validate_linestyle(ls):
11001106 'mathtext.fallback_to_cm' : [True , validate_bool ],
11011107
11021108 '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
11051111 'image.lut' : [256 , validate_int ], # lookup table
1106- 'image.origin' : ['upper' , six . text_type ], # lookup table
1112+ 'image.origin' : ['upper' , validate_string ], # lookup table
11071113 'image.resample' : [True , validate_bool ],
11081114 # Specify whether vector graphics backends will combine all images on a
11091115 # set of axes into a single composite image
@@ -1130,7 +1136,7 @@ def _validate_linestyle(ls):
11301136
11311137 'axes.titlesize' : ['large' , validate_fontsize ], # fontsize of the
11321138 # 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
11341140 'axes.titlepad' : [6.0 , validate_float ], # pad from axes top to title in points
11351141 'axes.grid' : [False , validate_bool ], # display grid or not
11361142 'axes.grid.which' : ['major' , validate_axis_locator ], # set wether the gid are by
@@ -1142,7 +1148,7 @@ def _validate_linestyle(ls):
11421148 'axes.labelsize' : ['medium' , validate_fontsize ], # fontsize of the
11431149 # x any y labels
11441150 '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
11461152 'axes.labelcolor' : ['k' , validate_color ], # color of axis label
11471153 'axes.formatter.limits' : [[- 7 , 7 ], validate_nseq_int (2 )],
11481154 # use scientific notation if log10
@@ -1187,16 +1193,16 @@ def _validate_linestyle(ls):
11871193 'axes3d.grid' : [True , validate_bool ], # display 3d grid
11881194
11891195 # scatter props
1190- 'scatter.marker' : ['o' , six . text_type ],
1196+ 'scatter.marker' : ['o' , validate_string ],
11911197
11921198 # 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 ],
12001206
12011207 #legend properties
12021208 'legend.fancybox' : [True , validate_bool ],
@@ -1249,7 +1255,7 @@ def _validate_linestyle(ls):
12491255
12501256 # fontsize of the xtick labels
12511257 'xtick.labelsize' : ['medium' , validate_fontsize ],
1252- 'xtick.direction' : ['out' , six . text_type ], # direction of xticks
1258+ 'xtick.direction' : ['out' , validate_string ], # direction of xticks
12531259 'xtick.alignment' : ["center" , _validate_alignment ],
12541260
12551261 'ytick.left' : [True , validate_bool ], # draw ticks on the left side
@@ -1269,7 +1275,7 @@ def _validate_linestyle(ls):
12691275
12701276 # fontsize of the ytick labels
12711277 'ytick.labelsize' : ['medium' , validate_fontsize ],
1272- 'ytick.direction' : ['out' , six . text_type ], # direction of yticks
1278+ 'ytick.direction' : ['out' , validate_string ], # direction of yticks
12731279 'ytick.alignment' : ["center_baseline" , _validate_alignment ],
12741280
12751281
@@ -1282,7 +1288,7 @@ def _validate_linestyle(ls):
12821288 ## figure props
12831289 # figure title
12841290 'figure.titlesize' : ['large' , validate_fontsize ],
1285- 'figure.titleweight' : ['normal' , six . text_type ],
1291+ 'figure.titleweight' : ['normal' , validate_string ],
12861292
12871293 # figure size in inches: width by height
12881294 'figure.figsize' : [[6.4 , 4.8 ], validate_nseq_float (2 )],
@@ -1320,7 +1326,7 @@ def _validate_linestyle(ls):
13201326 'savefig.bbox' : ['standard' , validate_bbox ],
13211327 'savefig.pad_inches' : [0.1 , validate_float ],
13221328 # default directory in savefig dialog box
1323- 'savefig.directory' : ['~' , six . text_type ],
1329+ 'savefig.directory' : ['~' , validate_string ],
13241330 'savefig.transparent' : [False , validate_bool ],
13251331
13261332 # Maintain shell focus for TkAgg
@@ -1361,7 +1367,7 @@ def _validate_linestyle(ls):
13611367 # set this when you want to generate hardcopy docstring
13621368 'docstring.hardcopy' : [False , validate_bool ],
13631369 # where plugin directory is locate
1364- 'plugins.directory' : ['.matplotlib_plugins' , six . text_type ],
1370+ 'plugins.directory' : ['.matplotlib_plugins' , validate_string ],
13651371
13661372 'path.simplify' : [True , validate_bool ],
13671373 'path.simplify_threshold' : [1.0 / 9.0 , ValidateInterval (0.0 , 1.0 )],
@@ -1387,15 +1393,15 @@ def _validate_linestyle(ls):
13871393 'keymap.all_axes' : [['a' ], validate_stringlist ],
13881394
13891395 # sample data
1390- 'examples.directory' : ['' , six . text_type ],
1396+ 'examples.directory' : ['' , validate_string ],
13911397
13921398 # Animation settings
13931399 'animation.html' : ['none' , validate_movie_html_fmt ],
13941400 # Limit, in MB, of size of base64 encoded animation in HTML
13951401 # (i.e. IPython notebook)
13961402 'animation.embed_limit' : [20 , validate_float ],
13971403 'animation.writer' : ['ffmpeg' , validate_movie_writer ],
1398- 'animation.codec' : ['h264' , six . text_type ],
1404+ 'animation.codec' : ['h264' , validate_string ],
13991405 'animation.bitrate' : [- 1 , validate_int ],
14001406 # Controls image format when frames are written to disk
14011407 'animation.frame_format' : ['png' , validate_movie_frame_fmt ],
0 commit comments