FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

FIX: allow zero and one as dates via wrapping by jklymak · Pull Request #15416 · matplotlib/matplotlib · GitHub

Repository navigation

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 3 additions & 12 deletions lib/matplotlib/dates.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ def _from_ordinalf(x, tz=None):

ix, remainder = divmod(x, 1)
ix = int(ix)
# force to valid date via wrapping....
dt10k = 3652059
ix = (ix - 1) % dt10k + 1
if ix < 1:
raise ValueError('Cannot convert {} to a date. This often happens if '
'non-datetime values are passed to an axis that '
Expand Down Expand Up @@ -1077,12 +1080,6 @@ def datalim_to_dt(self):
dmin, dmax = self.axis.get_data_interval()
if dmin > dmax:
dmin, dmax = dmax, dmin
if dmin < 1:
raise ValueError('datalim minimum {} is less than 1 and '
'is an invalid Matplotlib date value. This often '
'happens if you pass a non-datetime '
'value to an axis that has datetime units'
.format(dmin))
return num2date(dmin, self.tz), num2date(dmax, self.tz)

def viewlim_to_dt(self):
Expand All @@ -1092,12 +1089,6 @@ def viewlim_to_dt(self):
vmin, vmax = self.axis.get_view_interval()
if vmin > vmax:
vmin, vmax = vmax, vmin
if vmin < 1:
raise ValueError('view limit minimum {} is less than 1 and '
'is an invalid Matplotlib date value. This '
'often happens if you pass a non-datetime '
'value to an axis that has datetime units'
.format(vmin))
return num2date(vmin, self.tz), num2date(vmax, self.tz)

def _get_unit(self):
Expand Down

Back | FazBrowse Home | New Git URL