climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject [06/16] git commit: CLIMATE-392 - Minor testing for new helper
Date Sat, 05 Apr 2014 05:05:26 GMT
CLIMATE-392 - Minor testing for new helper

- Add a really simple sanity check test for the new
  normalize_lat_lon_values helper. We definitely need to add more tests
  for this when time permits.


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

Branch: refs/heads/master
Commit: 0497913cd56fa96ea507765e801ccacd537410c4
Parents: 5c41b95
Author: Michael Joyce <joyce@apache.org>
Authored: Fri Apr 4 20:52:07 2014 -0700
Committer: Michael Joyce <joyce@apache.org>
Committed: Fri Apr 4 20:52:07 2014 -0700

----------------------------------------------------------------------
 ocw/tests/test_utils.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/0497913c/ocw/tests/test_utils.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_utils.py b/ocw/tests/test_utils.py
index 8dbcfb6..4ca63c0 100644
--- a/ocw/tests/test_utils.py
+++ b/ocw/tests/test_utils.py
@@ -21,6 +21,7 @@ import os
 import datetime
 
 import netCDF4
+import numpy as np
 
 import ocw.utils as utils
 
@@ -83,5 +84,19 @@ class TestBaseTimeStringParse(unittest.TestCase):
             'this string is not valid'
         )
 
+class TestNormalizeLatLonValues(unittest.TestCase):
+    def setUp(self):
+        times = np.array([datetime.datetime(2000, x, 1) for x in range(1, 13)])
+        self.lats = np.array(range(-30, 30))
+        self.lons = np.array(range(360))
+        flat_array = np.array(range(len(times) * len(self.lats) * len(self.lons)))
+        self.values = flat_array.reshape(len(times), len(self.lats), len(self.lons))
+
+    def test_full_lons_shift(self):
+        lats, lons, values = utils.normalize_lat_lon_values(self.lats,
+                                                            self.lons,
+                                                            self.values)
+        self.assertTrue(np.array_equal(lons, range(-180, 180)))
+
 if __name__ == '__main__':
     unittest.main()


Mime
View raw message