8000 BUG : fixes non-float args to stem by tacaswell · Pull Request #2839 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

BUG : fixes non-float args to stem #2839

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import six
from six.moves import reduce, xrange, zip
from six import string_types

import math
import warnings
Expand Down Expand Up @@ -2285,19 +2286,28 @@ def stem(self, *args, **kwargs):
self.cla()
self.hold(True)

# Assume there's at least one data array
y = np.asarray(args[0], dtype=np.float)
args = args[1:]

# Try a second one
try:
second = np.asarray(args[0], dtype=np.float)
x, y = y, second
args = args[1:]
except (IndexError, ValueError):
# The second array doesn't make sense, or it doesn't exist
second = np.arange(len(y))
x = second
not_str_args = [not isinstance(a, string_types) for
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't the bug be fixed simply by leaving off the dtype specification here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, did not see that when I did this.

a in args]
if len(args) == 1:
y = args[0]
x = np.arange(len(y))
args = []
elif len(args) == 2:
if all(not_str_args):
x, y = args
args = []
else:
y = args[0]
x = np.arange(len(y))
args = []
else:
if all(not_str_args[:2]):
x, y = args[:2]
args = args[2:]
else:
y = args[0]
x = np.arange(len(y))
args = args[1:]

# Popping some defaults
try:
Expand Down
0