Revision: 6254
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6254&view=rev
Author: jswhit
Date: 2008-10-18 01:15:15 +0000 (Sat, 18 Oct 2008)
Log Message:
-----------
move tests to separate file.
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Added Paths:
-----------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/test.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-10-17
20:24:50 UTC (rev 6253)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-10-18
01:15:15 UTC (rev 6254)
@@ -3871,57 +3871,3 @@
"""
cdftime = netcdftime.utime(units,calendar=calendar)
return cdftime.date2num(dates)
-
-
-
-# beginnings of a test suite.
-
-from numpy.testing import NumpyTestCase,assert_almost_equal
-class TestRotateVector(NumpyTestCase):
- def make_array(self):
- lat = np.array([0, 45, 75, 90])
- lon = np.array([0,90,180,270])
- u = np.ones((len(lat), len(lon)))
- v = np.zeros((len(lat), len(lon)))
- return u,v,lat,lon
-
- def test_cylindrical(self):
- # Cylindrical case
- B = Basemap()
- u,v,lat,lon=self.make_array()
- ru, rv = B.rotate_vector(u,v, lon, lat)
-
- # Check that the vectors are identical.
- assert_almost_equal(ru, u)
- assert_almost_equal(rv, v)
-
- def test_nan(self):
- B = Basemap()
- u,v,lat,lon=self.make_array()
- # Set one element to 0, so that the vector magnitude is 0.
- u[1,1] = 0.
- ru, rv = B.rotate_vector(u,v, lon, lat)
- assert not np.isnan(ru).any()
- assert_almost_equal(u, ru)
- assert_almost_equal(v, rv)
-
- def test_npstere(self):
- # NP Stereographic case
- B=Basemap(projection='npstere', boundinglat=50., lon_0=0.)
- u,v,lat,lon=self.make_array()
- v = np.ones((len(lat), len(lon)))
-
- ru, rv = B.rotate_vector(u,v, lon, lat)
-
- assert_almost_equal(ru[2, :],[1,-1,-1,1], 6)
- assert_almost_equal(rv[2, :],[1,1,-1,-1], 6)
-
-def test():
- """
- Run some tests.
- """
- import unittest
- suite = unittest.makeSuite(TestRotateVector,'test')
- runner = unittest.TextTestRunner()
- runner.run(suite)
-
Added: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/test.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/test.py
(rev 0)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/test.py 2008-10-18
01:15:15 UTC (rev 6254)
@@ -0,0 +1,56 @@
+from mpl_toolkits.basemap import Basemap
+import numpy as np
+
+# beginnings of a test suite.
+
+from numpy.testing import NumpyTestCase,assert_almost_equal
+class TestRotateVector(NumpyTestCase):
+ def make_array(self):
+ lat = np.array([0, 45, 75, 90])
+ lon = np.array([0,90,180,270])
+ u = np.ones((len(lat), len(lon)))
+ v = np.zeros((len(lat), len(lon)))
+ return u,v,lat,lon
+
+ def test_cylindrical(self):
+ # Cylindrical case
+ B = Basemap()
+ u,v,lat,lon=self.make_array()
+ ru, rv = B.rotate_vector(u,v, lon, lat)
+
+ # Check that the vectors are identical.
+ assert_almost_equal(ru, u)
+ assert_almost_equal(rv, v)
+
+ def test_nan(self):
+ B = Basemap()
+ u,v,lat,lon=self.make_array()
+ # Set one element to 0, so that the vector magnitude is 0.
+ u[1,1] = 0.
+ ru, rv = B.rotate_vector(u,v, lon, lat)
+ assert not np.isnan(ru).any()
+ assert_almost_equal(u, ru)
+ assert_almost_equal(v, rv)
+
+ def test_npstere(self):
+ # NP Stereographic case
+ B=Basemap(projection='npstere', boundinglat=50., lon_0=0.)
+ u,v,lat,lon=self.make_array()
+ v = np.ones((len(lat), len(lon)))
+
+ ru, rv = B.rotate_vector(u,v, lon, lat)
+
+ assert_almost_equal(ru[2, :],[1,-1,-1,1], 6)
+ assert_almost_equal(rv[2, :],[1,1,-1,-1], 6)
+
+def test():
+ """
+ Run some tests.
+ """
+ import unittest
+ suite = unittest.makeSuite(TestRotateVector,'test')
+ runner = unittest.TextTestRunner()
+ runner.run(suite)
+
+if __name__ == '__main__':
+ test()
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins