| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,8 @@ | |||
| 6 | 6 | ||
| 7 | 7 | import six | |
| 8 | 8 | ||
| 9 | + import logging | ||
| 10 | + | ||
| 9 | 11 | from matplotlib import rcParams | |
| 10 | 12 | import matplotlib.artist as artist | |
| 11 | 13 | from matplotlib.artist import allow_rasterization | |
@@ -22,6 +24,8 @@ | |||
| 22 | 24 | import numpy as np | |
| 23 | 25 | import warnings | |
| 24 | 26 | ||
| 27 | + _log = logging.getLogger(__name__) | ||
| 28 | + | ||
| 25 | 29 | GRIDLINE_INTERPOLATION_STEPS = 180 | |
| 26 | 30 | ||
| 27 | 31 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -120,7 +120,6 @@ | |||
| 120 | 120 | ||
| 121 | 121 | import six | |
| 122 | 122 | from six.moves import zip | |
| 123 | - from matplotlib import rcParams | ||
| 124 | 123 | import re | |
| 125 | 124 | import time | |
| 126 | 125 | import math | |
@@ -129,20 +128,22 @@ | |||
| 129 | 128 | ||
| 130 | 129 | import warnings | |
| 131 | 130 | ||
| 132 | - | ||
| 133 | 131 | from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY, | |
| 134 | 132 | MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, | |
| 135 | 133 | SECONDLY) | |
| 136 | 134 | from dateutil.relativedelta import relativedelta | |
| 137 | 135 | import dateutil.parser | |
| 136 | + import logging | ||
| 138 | 137 | import numpy as np | |
| 139 | 138 | ||
| 140 | 139 | ||
| 141 | 140 | import matplotlib | |
| 141 | + from matplotlib import rcParams | ||
| 142 | 142 | import matplotlib.units as units | |
| 143 | 143 | import matplotlib.cbook as cbook | |
| 144 | 144 | import matplotlib.ticker as ticker | |
| 145 | 145 | ||
| 146 | + _log = logging.getLogger(__name__) | ||
| 146 | 147 | ||
| 147 | 148 | __all__ = ('date2num', 'num2date', 'num2timedelta', 'drange', 'epoch2num', | |
| 148 | 149 | 'num2epoch', 'mx2num', 'DateFormatter', | |
@@ -282,6 +283,11 @@ def _from_ordinalf(x, tz=None): | |||
| 282 | 283 | tz = _get_rc_timezone() | |
| 283 | 284 | ||
| 284 | 285 | ix = int(x) | |
| 286 | + if ix < 1: | ||
| 287 | + raise ValueError('cannot convert {} < 1 to a date. This ' | ||
| 288 | + 'often happens if floats are passed to ' | ||
| 289 | + 'a Matplotlib axis that expects datetime objects. ' | ||
| 290 | + ''.format(ix)) | ||
| 285 | 291 | dt = datetime.datetime.fromordinal(ix).replace(tzinfo=UTC) | |
| 286 | 292 | ||
| 287 | 293 | remainder = float(x) - ix | |
@@ -941,7 +947,10 @@ def datalim_to_dt(self): | |||
| 941 | 947 | dmin, dmax = self.axis.get_data_interval() | |
| 942 | 948 | if dmin > dmax: | |
| 943 | 949 | dmin, dmax = dmax, dmin | |
| 944 | - | ||
| 950 | + if dmin < 1: | ||
| 951 | + raise ValueError('datalim minimum {} < 1. This often ' | ||
| 952 | + 'happens if you pass a float to an ' | ||
| 953 | + 'axis that has datetime units'.format(dmin)) | ||
| 945 | 954 | return num2date(dmin, self.tz), num2date(dmax, self.tz) | |
| 946 | 955 | ||
| 947 | 956 | def viewlim_to_dt(self): | |
@@ -951,7 +960,10 @@ def viewlim_to_dt(self): | |||
| 951 | 960 | vmin, vmax = self.axis.get_view_interval() | |
| 952 | 961 | if vmin > vmax: | |
| 953 | 962 | vmin, vmax = vmax, vmin | |
| 954 | - | ||
| 963 | + if vmin < 1: | ||
| 964 | + raise ValueError('view limit minimum {} < 1. This often ' | ||
| 965 | + 'happens if you pass a float to an ' | ||
| 966 | + 'axis that has datetime units'.format(vmin)) | ||
| 955 | 967 | return num2date(vmin, self.tz), num2date(vmax, self.tz) | |
| 956 | 968 | ||
| 957 | 969 | def _get_unit(self): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments