Skip to content

Commit c353bce

Browse files
committed
Move input validation to below conversion to array
1 parent 506bd99 commit c353bce

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4758,12 +4758,6 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
47584758
47594759
"""
47604760

4761-
for input in [('x', x), ('y1', y1), ('y2', y2)]:
4762-
if not (cbook.is_scalar(input[1]) or
4763-
cbook.is_scalar(cbook.safe_first_element(input[1]))):
4764-
raise ValueError('Input passed into argument "' + input[0] +
4765-
'" is not 1-dimensional.')
4766-
47674761
if not rcParams['_internal.classic_mode']:
47684762
color_aliases = mcoll._color_aliases
47694763
kwargs = cbook.normalize_kwargs(kwargs, color_aliases)
@@ -4781,6 +4775,11 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
47814775
y1 = ma.masked_invalid(self.convert_yunits(y1))
47824776
y2 = ma.masked_invalid(self.convert_yunits(y2))
47834777

4778+
for name, array in [('x', x), ('y1', y1), ('y2', y2)]:
4779+
if array.ndim > 1:
4780+
raise ValueError('Input passed into argument "' + name +
4781+
'" is not 1-dimensional.')
4782+
47844783
if y1.ndim == 0:
47854784
y1 = np.ones_like(x) * y1
47864785
if y2.ndim == 0:
@@ -4926,11 +4925,6 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
49264925
49274926
"""
49284927

4929-
for input in [('y', y), ('x1', x1), ('x2', x2), ('where', where)]:
4930-
if not cbook.is_scalar(cbook.safe_first_element(input[1])):
4931-
raise ValueError('Input passed into argument "' + input[0] +
4932-
'" is not 1-dimensional.')
4933-
49344928
if not rcParams['_internal.classic_mode']:
49354929
color_aliases = mcoll._color_aliases
49364930
kwargs = cbook.normalize_kwargs(kwargs, color_aliases)
@@ -4947,6 +4941,11 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
49474941
x1 = ma.masked_invalid(self.convert_xunits(x1))
49484942
x2 = ma.masked_invalid(self.convert_xunits(x2))
49494943

4944+
for array in [('x', x), ('y1', y1), ('y2', y2)]:
4945+
if array[1].ndim > 1:
4946+
raise ValueError('Input passed into argument "' + array[0] +
4947+
'" is not 1-dimensional.')
4948+
49504949
if x1.ndim == 0:
49514950
x1 = np.ones_like(y) * x1
49524951
if x2.ndim == 0:

0 commit comments

Comments
 (0)