-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
better input validation on fill_between
#7817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
506bd99
c353bce
72f6359
e702cd8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4757,6 +4757,7 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False, | |
for filling between two sets of x-values | ||
|
||
""" | ||
|
||
if not rcParams['_internal.classic_mode']: | ||
color_aliases = mcoll._color_aliases | ||
kwargs = cbook.normalize_kwargs(kwargs, color_aliases) | ||
|
@@ -4774,6 +4775,11 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False, | |
y1 = ma.masked_invalid(self.convert_yunits(y1)) | ||
y2 = ma.masked_invalid(self.convert_yunits(y2)) | ||
|
||
for name, array in [('x', x), ('y1', y1), ('y2', y2)]: | ||
if array.ndim > 1: | ||
raise ValueError('Input passed into argument "' + name + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
'" is not 1-dimensional.') | ||
|
||
if y1.ndim == 0: | ||
y1 = np.ones_like(x) * y1 | ||
if y2.ndim == 0: | ||
|
@@ -4918,6 +4924,7 @@ def fill_betweenx(self, y, x1, x2=0, where=None, | |
for filling between two sets of y-values | ||
|
||
""" | ||
|
||
if not rcParams['_internal.classic_mode']: | ||
color_aliases = mcoll._color_aliases | ||
kwargs = cbook.normalize_kwargs(kwargs, color_aliases) | ||
|
@@ -4934,6 +4941,11 @@ def fill_betweenx(self, y, x1, x2=0, where=None, | |
x1 = ma.masked_invalid(self.convert_xunits(x1)) | ||
x2 = ma.masked_invalid(self.convert_xunits(x2)) | ||
|
||
for array in [('x', x), ('y1', y1), ('y2', y2)]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there is a slight mistake here: the arguments are "y", "x1" and "x2". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, thanks! Will change it now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason not to use |
||
if array[1].ndim > 1: | ||
raise ValueError('Input passed into argument "' + array[0] + | ||
'" is not 1-dimensional.') | ||
|
||
if x1.ndim == 0: | ||
x1 = np.ones_like(y) * x1 | ||
if x2.ndim == 0: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍