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

Skip to content

Commit a652b6f

Browse files
authored
Merge pull request #15939 from timhoffm/capitalize-exception
Exceptions should start with a capital letter
2 parents 4bedd44 + bc14e50 commit a652b6f

File tree

12 files changed

+20
-16
lines changed

12 files changed

+20
-16
lines changed

examples/specialty_plots/radar_chart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def _gen_axes_patch(self):
8282
return RegularPolygon((0.5, 0.5), num_vars,
8383
radius=.5, edgecolor="k")
8484
else:
85-
raise ValueError("unknown value for 'frame': %s" % frame)
85+
raise ValueError("Unknown value for 'frame': %s" % frame)
8686

8787
def _gen_axes_spines(self):
8888
if frame == 'circle':
@@ -99,7 +99,7 @@ def _gen_axes_spines(self):
9999
+ self.transAxes)
100100
return {'polar': spine}
101101
else:
102-
raise ValueError("unknown value for 'frame': %s" % frame)
102+
raise ValueError("Unknown value for 'frame': %s" % frame)
103103

104104
register_projection(RadarAxes)
105105
return theta

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2902,7 +2902,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
29022902
x = np.atleast_1d(x.squeeze())
29032903

29042904
if np.any(x < 0):
2905-
raise ValueError("wedge sizes must be non negative values")
2905+
raise ValueError("Wedge sizes 'x' must be non negative values")
29062906

29072907
sx = x.sum()
29082908
if sx > 1:

lib/matplotlib/axis.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,8 @@ def set_ticks_position(self, position):
20132013
----------
20142014
position : {'top', 'bottom', 'both', 'default', 'none'}
20152015
"""
2016+
cbook._check_in_list(['top', 'bottom', 'both', 'default', 'none'],
2017+
position=position)
20162018
if position == 'top':
20172019
self.set_tick_params(which='both', top=True, labeltop=True,
20182020
bottom=False, labelbottom=False)
@@ -2032,7 +2034,7 @@ def set_ticks_position(self, position):
20322034
bottom=True, labelbottom=True)
20332035
self._tick_position = 'bottom'
20342036
else:
2035-
raise ValueError("invalid position: %s" % position)
2037+
assert False, "unhandled parameter not caught by _check_in_list"
20362038
self.stale = True
20372039

20382040
def tick_top(self):
@@ -2300,6 +2302,8 @@ def set_ticks_position(self, position):
23002302
----------
23012303
position : {'left', 'right', 'both', 'default', 'none'}
23022304
"""
2305+
cbook._check_in_list(['left', 'right', 'both', 'default', 'none'],
2306+
position=position)
23032307
if position == 'right':
23042308
self.set_tick_params(which='both', right=True, labelright=True,
23052309
left=False, labelleft=False)
@@ -2318,7 +2322,7 @@ def set_ticks_position(self, position):
23182322
self.set_tick_params(which='both', right=True, labelright=False,
23192323
left=True, labelleft=True)
23202324
else:
2321-
raise ValueError("invalid position: %s" % position)
2325+
assert False, "unhandled parameter not caught by _check_in_list"
23222326
self.stale = True
23232327

23242328
def tick_right(self):

lib/matplotlib/cm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def to_rgba(self, x, alpha=None, bytes=False, norm=True):
229229
elif x.shape[2] == 4:
230230
xx = x
231231
else:
232-
raise ValueError("third dimension must be 3 or 4")
232+
raise ValueError("Third dimension must be 3 or 4")
233233
if xx.dtype.kind == 'f':
234234
if norm and (xx.max() > 1 or xx.min() < 0):
235235
raise ValueError("Floating point image RGB values "

lib/matplotlib/dviread.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,14 @@ def _pre(self, i, num, den, mag, k):
457457
if i != 2:
458458
raise ValueError("Unknown dvi format %d" % i)
459459
if num != 25400000 or den != 7227 * 2**16:
460-
raise ValueError("nonstandard units in dvi file")
460+
raise ValueError("Nonstandard units in dvi file")
461461
# meaning: TeX always uses those exact values, so it
462462
# should be enough for us to support those
463463
# (There are 72.27 pt to an inch so 7227 pt =
464464
# 7227 * 2**16 sp to 100 in. The numerator is multiplied
465465
# by 10^5 to get units of 10**-7 meters.)
466466
if mag != 1000:
467-
raise ValueError("nonstandard magnification in dvi file")
467+
raise ValueError("Nonstandard magnification in dvi file")
468468
# meaning: LaTeX seems to frown on setting \mag, so
469469
# I think we can assume this is constant
470470
self.state = _dvistate.outer
@@ -653,7 +653,7 @@ def _read(self):
653653
elif byte == 248: # postamble (just some number of 248s)
654654
break
655655
else:
656-
raise ValueError("unknown vf opcode %d" % byte)
656+
raise ValueError("Unknown vf opcode %d" % byte)
657657

658658
def _init_packet(self, pl):
659659
if self.state != _dvistate.outer:

lib/matplotlib/font_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ def _json_decode(o):
901901
r.fname = os.path.join(mpl.get_data_path(), r.fname)
902902
return r
903903
else:
904-
raise ValueError("don't know how to deserialize __class__=%s" % cls)
904+
raise ValueError("Don't know how to deserialize __class__=%s" % cls)
905905

906906

907907
def json_dump(data, filename):

lib/matplotlib/gridspec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def _normalize(key, size, axis): # Includes last index.
225225
try:
226226
k1, k2 = key
227227
except ValueError:
228-
raise ValueError("unrecognized subplot spec")
228+
raise ValueError("Unrecognized subplot spec")
229229
num1, num2 = np.ravel_multi_index(
230230
[_normalize(k1, nrows, 0), _normalize(k2, ncols, 1)],
231231
(nrows, ncols))

lib/matplotlib/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ def get_window_extent(self, renderer=None):
13691369
elif callable(self.bbox):
13701370
return self.bbox(renderer)
13711371
else:
1372-
raise ValueError("unknown type of bbox")
1372+
raise ValueError("Unknown type of bbox")
13731373

13741374
def contains(self, mouseevent):
13751375
"""Test whether the mouse event occurred within the image."""

lib/matplotlib/patches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3991,7 +3991,7 @@ def __init__(self, posA=None, posB=None,
39913991
elif posA is None and posB is None and path is not None:
39923992
self._posA_posB = None
39933993
else:
3994-
raise ValueError("either posA and posB, or path need to provided")
3994+
raise ValueError("Either posA and posB, or path need to provided")
39953995

39963996
self.patchA = patchA
39973997
self.patchB = patchB

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def _option_boolean(arg):
178178
def _option_context(arg):
179179
if arg in [None, 'reset', 'close-figs']:
180180
return arg
181-
raise ValueError("argument should be None or 'reset' or 'close-figs'")
181+
raise ValueError("Argument should be None or 'reset' or 'close-figs'")
182182

183183

184184
def _option_format(arg):

lib/matplotlib/tests/test_ticker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ def logit_deformatter(string):
879879
if match:
880880
num, deno = float(match["num"]), float(match["deno"])
881881
return num / deno
882-
raise ValueError("not formatted by LogitFormatter")
882+
raise ValueError("Not formatted by LogitFormatter")
883883

884884
@pytest.mark.parametrize(
885885
"fx, x",

lib/mpl_toolkits/axisartist/grid_finder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def update(self, **kw):
204204
"tick_formatter2"]:
205205
setattr(self, k, kw[k])
206206
else:
207-
raise ValueError("unknown update property '%s'" % k)
207+
raise ValueError("Unknown update property '%s'" % k)
208208

209209

210210
@cbook.deprecated("3.2")

0 commit comments

Comments
 (0)