climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jarifibra...@apache.org
Subject climate git commit: CLIMATE-791 - temporal_subset does not work for month_start > month_end
Date Mon, 13 Jun 2016 17:54:46 GMT
Repository: climate
Updated Branches:
  refs/heads/master 436855092 -> a879f70df


CLIMATE-791 - temporal_subset does not work for month_start > month_end

- Fix temporal_subset function
- Add tests for temporal_subset function


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/a879f70d
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/a879f70d
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/a879f70d

Branch: refs/heads/master
Commit: a879f70df7a6e667c2eb9a8a6411555676bb790d
Parents: 4368550
Author: Ibrahim <jarifibrahim@gmail.com>
Authored: Thu May 12 01:40:34 2016 +0530
Committer: Ibrahim <jarifibrahim@gmail.com>
Committed: Mon Jun 13 23:23:52 2016 +0530

----------------------------------------------------------------------
 ocw/dataset_processor.py            |  2 --
 ocw/tests/test_dataset_processor.py | 22 ++++++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/a879f70d/ocw/dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py
index 00e9546..a259ad3 100755
--- a/ocw/dataset_processor.py
+++ b/ocw/dataset_processor.py
@@ -68,8 +68,6 @@ def temporal_subset(month_start, month_end, target_dataset, average_each_year=Fa
 
     time_index = np.sort(time_index)
 
-    time_index = time_index[np.where((time_index >= time_index_first) & (time_index
<= time_index_last))]
-
     time_index = list(time_index)
 
     new_dataset = ds.Dataset(target_dataset.lats,

http://git-wip-us.apache.org/repos/asf/climate/blob/a879f70d/ocw/tests/test_dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_dataset_processor.py b/ocw/tests/test_dataset_processor.py
index bde6faf..2301cda 100644
--- a/ocw/tests/test_dataset_processor.py
+++ b/ocw/tests/test_dataset_processor.py
@@ -29,6 +29,28 @@ import logging
 logging.basicConfig(level=logging.CRITICAL)
 
 
+class TestTemporalSubset(unittest.TestCase):
+
+    def setUp(self):
+        self.ten_year_dataset = ten_year_monthly_dataset()
+
+    def test_returned_dataset(self):
+        self.dataset_times = np.array([datetime.datetime(year, month, 1)
+                                       for year in range(2000, 2010)
+                                       for month in range(1, 6)])
+        self.tempSubset = dp.temporal_subset(1, 5, self.ten_year_dataset)
+        np.testing.assert_array_equal(
+            self.dataset_times, self.tempSubset.times)
+
+    def test_startMonth_greater_than_endMonth(self):
+        self.dataset_times = np.array([datetime.datetime(year, month, 1)
+                                       for year in range(2000, 2010)
+                                       for month in [1, 8, 9, 10, 11, 12]])
+        self.tempSubset = dp.temporal_subset(8, 1, self.ten_year_dataset)
+        np.testing.assert_array_equal(
+            self.dataset_times, self.tempSubset.times)
+
+
 class TestEnsemble(unittest.TestCase):
     def test_unequal_dataset_shapes(self):
         self.ten_year_dataset = ten_year_monthly_dataset()


Mime
View raw message