8000 FIX: bar mixed units, allow ValueError as well by jklymak · Pull Request #13187 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

FIX: bar mixed units, allow ValueError as well #13187

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

Merged
merged 3 commits into from
Jan 21, 2019
Merged
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2057,9 +2057,9 @@ def _convert_dx(dx, x0, xconv, convert):
dx = [convert(x0 + ddx) - x for ddx in dx]
if delist:
dx = dx[0]
except (TypeError, AttributeError) as e:
# but doesn't work for 'string' + float, so just
# see if the converter works on the float.
except Exception:
Copy link
Contributor

Choose a reason for hiding this comment

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

please leave a comment justifying (briefly) the nonspecific catch-everything behavior.

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't that catch everything?

Copy link
Contributor

Choose a reason for hiding this comment

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

In principle I'm ok with except Exception:, but for targetted code. That's a pretty big try block to be catching with Exception--a lot of unexpected behavior could happen in those lines. Is it possible to just wrap the try around dx = [convert(x0 + ddx) - x for ddx in dx]?

# if the above fails (for any reason) just fallback to what
# we do by default and convert dx by iteslf.
dx = convert(dx)
return dx

Expand Down
0