Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Fix for issue 5575 along with testing #6091
Conversation
mdboom
added the
needs_review
label
Mar 2, 2016
tacaswell
added this to the
1.5.2 (Critical bug fix release)
milestone
Mar 2, 2016
|
Can you add only png tests for this (and re-base the pdf/svg tests out of existence)? The reason is to keep the size of the repo down and to keep the tests as fast as possible. There is nothing backend dependent about this so testing it only on Agg should be enough. Other wise It is great when problems have simple fixes! Can you also put the explanation of why this fixed the problem in the commit message? |
|
Done. Let me know if I missed anything in the pull request/commit. |
|
Can you rebase this to only one commit? Currently the svg/pdf are still in the history which means they are (forever) in the repository. |
KyleBsingh
closed this
Mar 2, 2016
mdboom
removed the
needs_review
label
Mar 2, 2016
|
If you just keep pu |
tacaswell
reopened this
Mar 2, 2016
tacaswell
added the
needs_review
label
Mar 2, 2016
|
If you just keep (force) pushing to this branch github will 'do the right thing'. PRs track branches, not commits. |
QuLogic
commented on an outdated diff
Mar 2, 2016
| @@ -4335,6 +4337,50 @@ def test_pandas_indexing_hist(): | ||
| fig, axes = plt.subplots() | ||
| axes.hist(ser_2) | ||
| +@image_comparison(baseline_images=['date_timezone_x'], | ||
| + extensions=['png']) | ||
| +def test_date_timezone_x(): | ||
| + #Tests issue 5575 | ||
| + time_index = [pytz.timezone('Canada/Eastern').localize(datetime.datetime(year=2016, month=2, day=22, hour=x)) for x in range(3)] |
|
|
QuLogic
commented on an outdated diff
Mar 2, 2016
| @@ -4335,6 +4337,50 @@ def test_pandas_indexing_hist(): | ||
| fig, axes = plt.subplots() | ||
| axes.hist(ser_2) | ||
| +@image_comparison(baseline_images=['date_timezone_x'], | ||
| + extensions=['png']) | ||
| +def test_date_timezone_x(): | ||
| + #Tests issue 5575 | ||
| + time_index = [pytz.timezone('Canada/Eastern').localize(datetime.datetime(year=2016, month=2, day=22, hour=x)) for x in range(3)] | ||
| + | ||
| + #Same Timezone | ||
| + fig = plt.figure(figsize=(20,12)) | ||
| + plt.subplot(2, 1, 1) | ||
| + plt.plot_date(time_index, [3]*3, tz='Canada/Eastern') | ||
| + | ||
| + #Different Timezone | ||
| + plt.subplot(2, 1, 2) | ||
| + plt.plot_date(time_index, [3]*3, tz='UTC') | ||
| + |
QuLogic
Member
|
QuLogic
commented on an outdated diff
Mar 2, 2016
QuLogic
commented on an outdated diff
Mar 2, 2016
| @@ -4335,6 +4337,50 @@ def test_pandas_indexing_hist(): | ||
| fig, axes = plt.subplots() | ||
| axes.hist(ser_2) | ||
| +@image_comparison(baseline_images=['date_timezone_x'], | ||
| + extensions=['png']) | ||
| +def test_date_timezone_x(): | ||
| + #Tests issue 5575 | ||
| + time_index = [pytz.timezone('Canada/Eastern').localize(datetime.datetime(year=2016, month=2, day=22, hour=x)) for x in range(3)] | ||
| + | ||
| + #Same Timezone | ||
| + fig = plt.figure(figsize=(20,12)) |
|
|
QuLogic
commented on an outdated diff
Mar 2, 2016
| @@ -4335,6 +4337,50 @@ def test_pandas_indexing_hist(): | ||
| fig, axes = plt.subplots() | ||
| axes.hist(ser_2) | ||
| +@image_comparison(baseline_images=['date_timezone_x'], | ||
| + extensions=['png']) | ||
| +def test_date_timezone_x(): | ||
| + #Tests issue 5575 | ||
| + time_index = [pytz.timezone('Canada/Eastern').localize(datetime.datetime(year=2016, month=2, day=22, hour=x)) for x in range(3)] | ||
| + | ||
| + #Same Timezone | ||
| + fig = plt.figure(figsize=(20,12)) | ||
| + plt.subplot(2, 1, 1) | ||
| + plt.plot_date(time_index, [3]*3, tz='Canada/Eastern') |
|
|
|
Sorry about earlier, I mis-clicked "Close and comment" instead of "comment". I have rebased and made the pep8 changes that I admittedly forgot to do. Thank you |
tacaswell
merged commit e47bc04
into matplotlib:master
Mar 13, 2016
tacaswell
added a commit
that referenced
this pull request
Mar 13, 2016
|
|
tacaswell |
ee1a98c
|
tacaswell
removed the
needs_review
label
Mar 13, 2016
tacaswell
added a commit
that referenced
this pull request
Mar 13, 2016
|
|
tacaswell |
44afc73
|
QuLogic
added the
date handling
label
Mar 13, 2016
tacaswell
added a commit
to tacaswell/matplotlib
that referenced
this pull request
May 22, 2016
|
|
tacaswell |
7d3a894
|
KyleBsingh commentedMar 2, 2016
This is a pull request to resolve issue #5575.
Tracing calls made in plot_date() I realized it was ignoring timezones as a result of the axis being set while plotting, then trying to change the time zone.
In line 1427 of axis.py we have
converter = munits.registry.get_converter(data). Unfortunately for setting the timezone the converter will be the same as when it was plotted originally. Thus in the following lines 1433-1435 we will not be able to set_units.My solution to this was to make sure that instead of the following in _axes.py's plot_data:
we have:
This ensures the plot has the correct timezone, and it also plots the correct data onto the plot.
I have added test cases to /lib/matplotlib/tests/test_axes which has tests for the same and different timezones in the x axis, y axis, and both the x and y axis