From af2ba98068fda34e2eb9ee55bb16723cadc217a0 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sun, 13 Oct 2019 21:26:55 -0700 Subject: [PATCH] FIX: allow zero and one as dates via wrapping --- lib/matplotlib/dates.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index 350b6815b411..2b3a9a8e08da 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -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 ' @@ -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): @@ -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): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy