Skip to content

Catch warning thrown in Mollweide projection. #3282

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 2 commits into from
Aug 26, 2014
Merged
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
39 changes: 25 additions & 14 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,20 +1010,31 @@ def _update_ticks(self, renderer):
# the idea that one would rather potentially lose a tick
# from one side of the axis or another, rather than see a
# stack trace.
try:
ds1 = self._get_pixel_distance_along_axis(interval_expanded[0], -0.5)
except:
warnings.warn("Unable to find pixel distance along axis for interval padding; assuming no interval padding needed.")
ds1 = 0.0
if np.isnan(ds1):
ds1 = 0.0
try:
ds2 = self._get_pixel_distance_along_axis(interval_expanded[1], +0.5)
except:
warnings.warn("Unable to find pixel distance along axis for interval padding; assuming no interval padding needed.")
ds2 = 0.0
if np.isnan(ds2):
ds2 = 0.0
# We also catch users warnings here. These are the result of
# invalid numpy calculations that may be the result of out of
# bounds on axis with finite allowed intervals such as geo
# projections i.e. Mollweide.
with np.errstate(invalid='ignore'):
try:
ds1 = self._get_pixel_distance_along_axis(
interval_expanded[0], -0.5)
except:
warnings.warn("Unable to find pixel distance along axis for\
interval padding of ticks; assuming no interval padding\
needed.")
ds1 = 0.0
if np.isnan(ds1):
ds1 = 0.0
try:
ds2 = self._get_pixel_distance_along_axis(
interval_expanded[1], +0.5)
except:
warnings.warn("Unable to find pixel distance along axis for\
interval padding of ticks; assuming no interval padding\
needed.")
ds2 = 0.0
if np.isnan(ds2):
ds2 = 0.0
interval_expanded = (interval_expanded[0] - ds1,
interval_expanded[1] + ds2)

Expand Down