-
Notifications
You must be signed in to change notification settings - Fork 32
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
Unpin mpl #34
Unpin mpl #34
Changes from 4 commits
9d41cc5
bdccddd
5bce0d3
b12290e
8fcb5b0
4d9df15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,17 @@ | |
from __future__ import (absolute_import, division, print_function) | ||
from six.moves import (filter, input, map, range, zip) # noqa | ||
|
||
import sys | ||
import unittest | ||
|
||
import cftime | ||
import numpy as np | ||
|
||
from nc_time_axis import NetCDFTimeConverter, CalendarDateTime | ||
|
||
if sys.version_info[:2] == (2, 7): | ||
unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ocefpaf Could we not just use We'd need to add it as an dependency... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. Let me update that. |
||
|
||
class Test_axisinfo(unittest.TestCase): | ||
def test_axis_default_limits(self): | ||
|
@@ -56,7 +60,7 @@ def test_nonequal_calendars(self): | |
unit = 'days since 2000-01-01' | ||
val = [CalendarDateTime(cftime.datetime(2014, 8, 12), calendar_1), | ||
CalendarDateTime(cftime.datetime(2014, 8, 13), calendar_2)] | ||
with self.assertRaisesRegexp(ValueError, 'not all equal'): | ||
with self.assertRaisesRegex(ValueError, 'not all equal'): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you agree to using with assertRaisesRegex(self, ValueError, 'not all equal') : etc |
||
NetCDFTimeConverter().default_units(val, None) | ||
|
||
|
||
|
@@ -98,14 +102,14 @@ def test_non_cftime_datetime(self): | |
val = CalendarDateTime(4, '360_day') | ||
msg = 'The datetime attribute of the CalendarDateTime object must ' \ | ||
'be of type `cftime.datetime`.' | ||
with self.assertRaisesRegexp(ValueError, msg): | ||
with self.assertRaisesRegex(ValueError, msg): | ||
result = NetCDFTimeConverter().convert(val, None, None) | ||
|
||
def test_non_CalendarDateTime(self): | ||
val = cftime.datetime(1988, 5, 6) | ||
msg = 'The values must be numbers or instances of ' \ | ||
'"nc_time_axis.CalendarDateTime".' | ||
with self.assertRaisesRegexp(ValueError, msg): | ||
with self.assertRaisesRegex(ValueError, msg): | ||
result = NetCDFTimeConverter().convert(val, None, None) | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,17 @@ | |
|
||
import unittest | ||
|
||
import matplotlib.style | ||
import matplotlib.dates as mdates | ||
import cftime | ||
import numpy as np | ||
|
||
from nc_time_axis import NetCDFTimeDateLocator | ||
|
||
|
||
matplotlib.style.use('classic') | ||
|
||
|
||
class Test_compute_resolution(unittest.TestCase): | ||
def setUp(self): | ||
self.date_unit = 'days since 2004-01-01 00:00' | ||
|
@@ -108,7 +112,7 @@ def test_monthly(self): | |
|
||
def test_yearly(self): | ||
np.testing.assert_array_equal( | ||
self.check(5, 0, 5*365), [31., 638., 1246., 1856.]) | ||
self.check(5, 0, 5*365), [31., 485., 942., 1399., 1856.]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the change in the steps, and taking advantage of the |
||
|
||
|
||
if __name__ == "__main__": | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
author='Laura Dreyer, Philip Elson', | ||
url='https://github.com/scitools/nc-time-axis', | ||
packages=packages, | ||
install_requires = ['matplotlib==1.*', | ||
install_requires = ['matplotlib', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not your doing, but let's put these in alphabetical order, thanks. |
||
'cftime', | ||
'numpy', | ||
'six'], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs mention that this should be between 1 and 10 but I'm not sure that is the ideal steps for
nc-time-axis
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Holy 💩 ... I've just joined the dots here!
During the marathon that was SciTools/iris#3019, I raised the issue SciTools/iris#3019 to capture the oddity of a documentation example graphical test that is raising a
UserWarning
from withinmpl
...After digging a little, it turns out that the plot in question

uses
nc-time-axis
to plot time on thexaxis
... and the weird step values that are being passed into thematplotlib.ticker.MaxNLocator
that cause it to raise theUserWarning
are[1, 2, 4, 7, 14]
no less!Awesome! So
nc-time-axis
is indeed the root cause.I'll play with the steps to see the impact on plots...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me a while to figure that out just to find out that @QuLogic already solved this last year 😄
#23 (comment)