climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jarifibra...@apache.org
Subject [1/6] climate git commit: Add temporal_slice function tests
Date Tue, 14 Jun 2016 06:38:07 GMT
Repository: climate
Updated Branches:
  refs/heads/master 71c8a502e -> d94bbdc05


Add temporal_slice function tests


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

Branch: refs/heads/master
Commit: 3a0467f32ddd672c72ba361e04d0a51f8773854e
Parents: fb53c09
Author: Ibrahim <jarifibrahim@gmail.com>
Authored: Mon May 30 15:54:39 2016 +0530
Committer: Ibrahim <jarifibrahim@gmail.com>
Committed: Tue Jun 14 01:06:10 2016 +0530

----------------------------------------------------------------------
 ocw/tests/test_dataset_processor.py | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/3a0467f3/ocw/tests/test_dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_dataset_processor.py b/ocw/tests/test_dataset_processor.py
index c186e4b..093e510 100644
--- a/ocw/tests/test_dataset_processor.py
+++ b/ocw/tests/test_dataset_processor.py
@@ -157,6 +157,31 @@ class TestVariableUnitConversion(unittest.TestCase):
         np.testing.assert_array_equal(self.ten_year_dataset.values, values)
 
 
+class TestTemporalSlice(unittest.TestCase):
+    def test_returned_dataset_times(self):
+        ''' Tests returned dataset times values '''
+        self.ten_year_dataset = ten_year_monthly_dataset()
+        start_index = 1
+        end_index = 4
+        dates = np.array([datetime.datetime(2000, month, 1)
+                          for month in range(start_index + 1, end_index + 2)])
+        new_dataset = dp.temporal_slice(start_index,
+                                        end_index,
+                                        self.ten_year_dataset)
+        np.testing.assert_array_equal(new_dataset.times, dates)
+
+    def test_returned_dataset_values(self):
+        ''' Tests returned dataset variable values '''
+        self.ten_year_dataset = ten_year_monthly_dataset()
+        start_index = 1
+        end_index = 4
+        values = self.ten_year_dataset.values[start_index:end_index + 1]
+        new_dataset = dp.temporal_slice(start_index,
+                                        end_index,
+                                        self.ten_year_dataset)
+        np.testing.assert_array_equal(new_dataset.values, values)
+
+
 class TestEnsemble(unittest.TestCase):
     def test_unequal_dataset_shapes(self):
         self.ten_year_dataset = ten_year_monthly_dataset()


Mime
View raw message