CLIMATE-341: Adjust formatting for pep8 compliance
Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/b18d4d0d Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/b18d4d0d Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/b18d4d0d Branch: refs/heads/master Commit: b18d4d0d1515af825224f33f294ed062bea0bf53 Parents: b9dcdcd Author: rlaidlaw <[email protected]> Authored: Tue Oct 28 09:42:11 2014 -0700 Committer: rlaidlaw <[email protected]> Committed: Tue Oct 28 09:42:11 2014 -0700 ---------------------------------------------------------------------- ocw/tests/test_utils.py | 7 +++++-- ocw/utils.py | 9 +++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/b18d4d0d/ocw/tests/test_utils.py ---------------------------------------------------------------------- diff --git a/ocw/tests/test_utils.py b/ocw/tests/test_utils.py index 2c0981c..da5ad42 100644 --- a/ocw/tests/test_utils.py +++ b/ocw/tests/test_utils.py @@ -203,10 +203,13 @@ class TestCalcClimatologyMonthly(unittest.TestCase): def setUp(self): self.lats = np.array([10, 20, 30, 40, 50]) self.lons = np.array([20, 30, 40, 50, 60]) - self.times = np.array([datetime.datetime(2000, 1, 1) + relativedelta(months = x) for x in range(36)]) + start_date = datetime.datetime(2000, 1, 1) + self.times = np.array([start_date + relativedelta(months=x) + for x in range(36)]) self.values = np.array([1]*300 + [2]*300 + [0]*300).reshape(36, 5, 5) self.variable = 'testdata' - self.dataset = Dataset(self.lats, self.lons, self.times, self.values, self.variable) + self.dataset = Dataset(self.lats, self.lons, self.times, + self.values, self.variable) def test_calc_climatology_monthly(self): expected_result = np.ones(300).reshape(12, 5, 5) http://git-wip-us.apache.org/repos/asf/climate/blob/b18d4d0d/ocw/utils.py ---------------------------------------------------------------------- diff --git a/ocw/utils.py b/ocw/utils.py index 0d8d8b5..defe3d1 100644 --- a/ocw/utils.py +++ b/ocw/utils.py @@ -316,7 +316,8 @@ def calc_climatology_season(month_start, month_end, dataset): def calc_climatology_monthly(dataset): ''' Calculate monthly mean values for a dataset. - :param dataset: Monthly binned Dataset object with the number of months divisible by 12 + :param dataset: Monthly binned Dataset object with the number of months + divisible by 12 :type dataset: ocw.dataset.Dataset object :returns: Mean values for each month of the year @@ -326,7 +327,11 @@ def calc_climatology_monthly(dataset): ''' if dataset.values.shape[0] % 12: - raise ValueError("The length of the time axis in the values array should be divisible by 12.") + error = ( + "The length of the time axis in the values array should be " + "divisible by 12." + ) + raise ValueError(error) else: return reshape_monthly_to_annually(dataset).mean(axis=0)
