Skip to content

Date fixes #3947

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 23 commits into from
Jul 22, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
621a840
Clean up docstrings (convert several single-quote string comments to …
pganssle Dec 24, 2014
504044e
Small expansions to docstrings in the date library.
pganssle Dec 24, 2014
390c1f4
Moved all the "magic numbers" into some centrally defined constants f…
pganssle Dec 24, 2014
5af753c
Replace hard-coded conversion logic in _to_ordinalf with functions fr…
pganssle Dec 24, 2014
ee7931c
Make `from_ordinalf` use mostly functions from `datetime` for time co…
pganssle Dec 24, 2014
4b0d94b
Fix issue causing failed builds.
pganssle Dec 25, 2014
ba623a7
Fix problem with inconsistent time zones. This now also fixes Issue #…
pganssle Dec 25, 2014
9f66ae2
Didn't realize that `_to_ordinalf` needs to support datetime.date obj…
pganssle Dec 25, 2014
d61397d
PEP8 fix.
pganssle Dec 25, 2014
0a5fbc6
Fix timezone issue, update code to coding standards.
pganssle Dec 26, 2014
72ef748
Fix timezone problem, clarify docstring for timezones.
pganssle Dec 26, 2014
7fd2d36
Fixed issue with `_to_ordinalf()`, should work fine now. Build will s…
pganssle Dec 26, 2014
2f80916
Change behavior of `get_locator` to accurately calculate number of da…
pganssle Dec 27, 2014
ca284d1
Absolute value must apply to timedelta object as well as reslative de…
pganssle Dec 27, 2014
68f3018
Adjust calculation of `numSeconds` and `numMicroseconds`, since the `…
pganssle Dec 27, 2014
88e6e1e
Another adjustment to allow external libraries to do the calcs for us.
pganssle Dec 27, 2014
0de1e84
Adjusted test_dates to account for the minor change in behavior of th…
pganssle Dec 28, 2014
f585a17
Adjusted rounding logic in `_from_ordinalf` to be consistent with pre…
Dec 28, 2014
2a0865b
Add alias for total_seconds() to support Python 2.6
Dec 28, 2014
f1f6d8f
Cleaner way to test for existence of `total_seconds()`.
Dec 28, 2014
46a4a0a
Tighten up `_total_seconds()` alias.
Dec 29, 2014
35b93d2
Support numpy arrays in DayLocator, WeekdayLocator and MonthLocator w…
Dec 30, 2014
ad55256
Modified strftime code so it only falls back to this other routine wh…
Jan 7, 2015
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
Prev Previous commit
Next Next commit
Adjusted test_dates to account for the minor change in behavior of th…
…e date locator.

Signed-off-by: Paul G <p.ganssle@gmail.com>
  • Loading branch information
pganssle committed Dec 28, 2014
commit 0de1e848635a497b116e154742b647ae7fe8524a
4 changes: 1 addition & 3 deletions lib/matplotlib/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,6 @@ class rrulewrapper(object):
def __init__(self, freq, **kwargs):
self._construct = kwargs.copy()
self._construct["freq"] = freq
print(self._construct)
self._rrule = rrule(**self._construct)

def set(self, **kwargs):
Expand Down Expand Up @@ -1270,8 +1269,7 @@ def _close_to_dt(d1, d2, epsilon=5):
Assert that datetimes *d1* and *d2* are within *epsilon* microseconds.
"""
delta = d2 - d1
mus = abs(delta.days * MUSECONDS_PER_DAY + delta.seconds * 1e6 +
delta.microseconds)
mus = abs(delta.total_seconds() * 1e6)
assert mus < epsilon


Expand Down
10 changes: 5 additions & 5 deletions lib/matplotlib/tests/test_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@ def _create_auto_date_locator(date1, date2):
'1990-09-01 00:00:00+00:00', '1990-10-01 00:00:00+00:00',
'1990-11-01 00:00:00+00:00', '1990-12-01 00:00:00+00:00']
],
[datetime.timedelta(days=140),
['1990-01-06 00:00:00+00:00', '1990-01-27 00:00:00+00:00',
'1990-02-17 00:00:00+00:00', '1990-03-10 00:00:00+00:00',
'1990-03-31 00:00:00+00:00', '1990-04-21 00:00:00+00:00',
'1990-05-12 00:00:00+00:00']
[datetime.timedelta(days=141),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember talking about this before, but not the conclusion. Why is it OK that the tests were changed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tacaswell It's an expected (minor) behavior change caused by an increase in the accuracy of the way marker locations are calculated. I think the change was in this commit; previously if the beginning and end dates were January 3rd, 2000 and June 10th, 2015, relativedelta object returns (years=15, months=5, days=7), and when get_locator() is called, it calculated the number of days between the dates assuming that the number of days per year is 365 and the number of days per month is 30, so the number of days calculated would be 5632 rather than the true value of 5637.

It's a small inaccuracy, but it's easy to fix by holding on to a timedelta object and using that when calculating days from years or months. As a result, some of the date range calculations are slightly different (though not to a degree that anyone would really notice), so at least one of the tests had to be updated (I vaguely remember updating one that was around 3 months and one that was around 3 weeks).

(Oops, responded to this in the PR not the line)

['1990-01-05 00:00:00+00:00', '1990-01-26 00:00:00+00:00',
'1990-02-16 00:00:00+00:00', '1990-03-09 00:00:00+00:00',
'1990-03-30 00:00:00+00:00', '1990-04-20 00:00:00+00:00',
'1990-05-11 00:00:00+00:00']
],
[datetime.timedelta(days=40),
['1990-01-03 00:00:00+00:00', '1990-01-10 00:00:00+00:00',
Expand Down