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
Make Axes.stem take at least one argument. #1139
Changes from 3 commits
eb953ba
6973b56
6c02993
db493b5
94f640e
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 |
---|---|---|
|
@@ -901,6 +901,20 @@ def test_hist_stacked_weighted(): | |
ax = fig.add_subplot(111) | ||
ax.hist( (d1, d2), weights=(w1,w2), histtype="stepfilled", stacked=True) | ||
|
||
@cleanup | ||
def test_stem_args(): | ||
fig = plt.figure() | ||
ax = fig.add_subplot(1, 1, 1) | ||
|
||
x = range(10) | ||
y = range(10) | ||
|
||
# Test the call signatures | ||
ax.stem(y) | ||
ax.stem(x, y) | ||
ax.stem(x, y, 'r--') | ||
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. This call (and the next) "works", but never actually gets the linefmt. It is left behind in *args. plot() and scatter() has to do this sort of crap too. Essentially, you go through all of the remaining positional args, supplying them for the defaults to the pops of the kwargs. |
||
ax.stem(x, y, 'r--', basefmt='b--') | ||
|
||
@image_comparison(baseline_images=['transparent_markers'], remove_text=True) | ||
def test_transparent_markers(): | ||
np.random.seed(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.
At the very least, catch Exception, but I would rather catch IndexError and whatever else might come from numpy (ValueError, maybe?)
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.
Yes, I wanted to catch both so didn't specify -- perhaps catching
Exception
also catches some magical python ponies that I am unaware of?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.
The
IndexError
comes fromargs[1]
being out of bounds. TheValueError
comes from the casting tonp.float
being invalid. This is the case in your example ofstem(x, 'r--')
.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.
If you want to catch both, then do
except (IndexError, ValueError):
. There is a difference betweenexcept:
andexcept Exception:
. See here: http://docs.python.org/2/howto/doanddont.html#exceptThere 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.
That's helpful -- thank you!