From 9d41cc5dffcd9b4cae254f52b32cba5d4a596963 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Mon, 28 May 2018 11:12:19 -0300 Subject: [PATCH 1/6] unpin mpl --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f0007dd..c0384c0 100644 --- a/setup.py +++ b/setup.py @@ -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', 'cftime', 'numpy', 'six'], From bdccddd666ec237faa3526278ca5c9a5f765fac6 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Mon, 28 May 2018 13:01:07 -0300 Subject: [PATCH 2/6] steps goes from 1 to 10 --- nc_time_axis/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nc_time_axis/__init__.py b/nc_time_axis/__init__.py index 3b42a96..4ea7850 100644 --- a/nc_time_axis/__init__.py +++ b/nc_time_axis/__init__.py @@ -97,7 +97,7 @@ def __init__(self, max_n_ticks, calendar, date_unit, min_n_ticks=3): self.min_n_ticks = min_n_ticks self._max_n_locator = mticker.MaxNLocator(max_n_ticks, integer=True) self._max_n_locator_days = mticker.MaxNLocator( - max_n_ticks, integer=True, steps=[1, 2, 4, 7, 14]) + max_n_ticks, integer=True, steps=[1, 2, 4, 7, 10]) self.calendar = calendar self.date_unit = date_unit if not self.date_unit.lower().startswith('days since'): From 5bce0d35e30f0779ebfd73b4b67195a1817b026a Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Mon, 28 May 2018 13:02:04 -0300 Subject: [PATCH 3/6] use classic to fix the last two tests --- nc_time_axis/tests/unit/test_NetCDFTimeDateLocator.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nc_time_axis/tests/unit/test_NetCDFTimeDateLocator.py b/nc_time_axis/tests/unit/test_NetCDFTimeDateLocator.py index 7e233b7..48ba8bd 100644 --- a/nc_time_axis/tests/unit/test_NetCDFTimeDateLocator.py +++ b/nc_time_axis/tests/unit/test_NetCDFTimeDateLocator.py @@ -5,6 +5,7 @@ import unittest +import matplotlib.style import matplotlib.dates as mdates import cftime import numpy as np @@ -12,6 +13,9 @@ 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.]) if __name__ == "__main__": From b12290e26d6ce2e10bf24c048550cf68f9682b74 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Mon, 28 May 2018 13:05:03 -0300 Subject: [PATCH 4/6] fix DeprecationWarnings --- nc_time_axis/tests/unit/test_NetCDFTimeConverter.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nc_time_axis/tests/unit/test_NetCDFTimeConverter.py b/nc_time_axis/tests/unit/test_NetCDFTimeConverter.py index dca5ca1..ed9f76a 100644 --- a/nc_time_axis/tests/unit/test_NetCDFTimeConverter.py +++ b/nc_time_axis/tests/unit/test_NetCDFTimeConverter.py @@ -3,6 +3,7 @@ from __future__ import (absolute_import, division, print_function) from six.moves import (filter, input, map, range, zip) # noqa +import sys import unittest import cftime @@ -10,6 +11,9 @@ from nc_time_axis import NetCDFTimeConverter, CalendarDateTime +if sys.version_info[:2] == (2, 7): + unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp + 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'): 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) From 8fcb5b016e9b4242a6c357950e6e278fdddc59b8 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Wed, 30 May 2018 15:08:54 -0300 Subject: [PATCH 5/6] deps in alphabetical order --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index c0384c0..3ac3be7 100644 --- a/setup.py +++ b/setup.py @@ -20,8 +20,8 @@ author='Laura Dreyer, Philip Elson', url='https://github.com/scitools/nc-time-axis', packages=packages, - install_requires = ['matplotlib', - 'cftime', + install_requires = ['cftime', + 'matplotlib', 'numpy', 'six'], tests_require = ['mock', 'pep8'], From 4d9df15656d72ba11aa75061eb9a963e2a4e1519 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Wed, 30 May 2018 15:12:03 -0300 Subject: [PATCH 6/6] use six --- nc_time_axis/tests/unit/test_NetCDFTimeConverter.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/nc_time_axis/tests/unit/test_NetCDFTimeConverter.py b/nc_time_axis/tests/unit/test_NetCDFTimeConverter.py index ed9f76a..da6634c 100644 --- a/nc_time_axis/tests/unit/test_NetCDFTimeConverter.py +++ b/nc_time_axis/tests/unit/test_NetCDFTimeConverter.py @@ -2,8 +2,8 @@ from __future__ import (absolute_import, division, print_function) from six.moves import (filter, input, map, range, zip) # noqa +from six import assertRaisesRegex -import sys import unittest import cftime @@ -11,9 +11,6 @@ from nc_time_axis import NetCDFTimeConverter, CalendarDateTime -if sys.version_info[:2] == (2, 7): - unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp - class Test_axisinfo(unittest.TestCase): def test_axis_default_limits(self): @@ -60,7 +57,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.assertRaisesRegex(ValueError, 'not all equal'): + with assertRaisesRegex(self, ValueError, 'not all equal'): NetCDFTimeConverter().default_units(val, None) @@ -102,14 +99,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.assertRaisesRegex(ValueError, msg): + with assertRaisesRegex(self, 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.assertRaisesRegex(ValueError, msg): + with assertRaisesRegex(self, ValueError, msg): result = NetCDFTimeConverter().convert(val, None, None)