Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6cfb937

Browse files
committed
Add comments and doc explaining comparison to None
1 parent 1642892 commit 6cfb937

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

lib/matplotlib/rcsetup.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,18 @@ def validate_float(s):
109109

110110

111111
def validate_float_or_None(s):
112-
"""convert s to float or raise"""
112+
"""convert s to float, None or raise"""
113+
# values directly from the rc file can only be strings,
114+
# so we need to recognize the string "None" and convert
115+
# it into the object. We will be case-sensitive here to
116+
# avoid confusion between string values of 'none', which
117+
# can be a valid string value for some other parameters.
113118
if s is None or s == 'None':
114119
return None
115120
try:
116121
return float(s)
117122
except ValueError:
118-
raise ValueError('Could not convert "%s" to float' % s)
123+
raise ValueError('Could not convert "%s" to float or None' % s)
119124

120125
def validate_dpi(s):
121126
"""confirm s is string 'figure' or convert s to float or raise"""

0 commit comments

Comments
 (0)