| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| if not isinstance(vmax, _datetimey): | ||
| vmax = _datetimey._datetime_to_datetimey(vmax, 0) | ||
| vmind, vmaxd = _datetimey._datetimey_to_datetime_samey0(vmin, vmax) | ||
| self.rule.set(dtstart=vmind, until=vmaxd) |
There was a problem hiding this comment.
Note that in the old code dstart=vmin-(vmax-vmin) for some reason, and dstop = vmax + (vmax - vmin). Expanding the range by a factor of three doesn't make much sense to me. The test that changed (test_DateFormatter), in my opinion, changed for the better. So this is a mildly breaking change, but it gives far more consistent results.
Sorry, something went wrong.
| MO, TU, WE, TH, FR, SA, SU) | ||
| WEEKDAYS = (MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY) | ||
|
|
||
| class _datetimey(datetime.datetime): |
There was a problem hiding this comment.
my guess is that this whole class should go in its own file...
Sorry, something went wrong.
|
Is this still relevant, now that we can set the epoch? |
Sorry, something went wrong.
|
Yeah, because it works around datetime's issues with years > 9999 and less than 0. datetime64 has no issues with those (other than typical calendar craziness) so it would be nice to do something. But was waiting for the epoch stuff to shake out first. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
This is a WIP, but for discussion as to whether this is worth the extra code.
It is easy to make negative datetime64 objects, or large datetime64 objects that are greater than 10000 years, whereas right now we restrict to between year 1 and 9999 because we use datetime.datetime.
The obvious solution is to use datetime64, but that falls down because a) we want to be able to deal with timezones, and datetime64 doesn't by default. b) we want to use dateutil.rrule for things like "put a tick every other Wednesday".
So, the solution proposed here is to derive a subclass of datetime that keeps track of more years than 1-9999 (I'm not actually clear why datetime restricts to these values in the first place). I've attempted (probably poorly) to make the subclass as minimal as possible, and to call the super as often as possible.
import matplotlib.pyplot as plt import numpy as np fig, ax = plt.subplots() dates = np.arange('-20000-01-01', '-20000-02-01', 10, dtype='datetime64[h]') y = np.arange(len(dates)) ax.plot(dates, y, 'd') plt.show()Before
This PR:
PR Checklist