@@ -13,7 +13,7 @@ def make_array(self):
1313 u = np .ones ((len (lat ), len (lon )))
1414 v = np .zeros ((len (lat ), len (lon )))
1515 return u ,v ,lat ,lon
16-
16+
1717 def test_cylindrical (self ):
1818 # Cylindrical case
1919 B = Basemap ()
@@ -22,7 +22,7 @@ def test_cylindrical(self):
2222 # Check that the vectors are identical.
2323 assert_almost_equal (ru , u )
2424 assert_almost_equal (rv , v )
25-
25+
2626 def test_nan (self ):
2727 B = Basemap ()
2828 u ,v ,lat ,lon = self .make_array ()
@@ -32,12 +32,12 @@ def test_nan(self):
3232 assert not np .isnan (ru ).any ()
3333 assert_almost_equal (u , ru )
3434 assert_almost_equal (v , rv )
35-
35+
3636 def test_npstere (self ):
3737 # NP Stereographic case
3838 B = Basemap (projection = 'npstere' , boundinglat = 50. , lon_0 = 0. )
3939 u ,v ,lat ,lon = self .make_array ()
40- v = np .ones ((len (lat ), len (lon )))
40+ v = np .ones ((len (lat ), len (lon )))
4141 ru , rv = B .rotate_vector (u ,v , lon , lat )
4242 assert_almost_equal (ru [2 , :],[1 ,- 1 ,- 1 ,1 ], 6 )
4343 assert_almost_equal (rv [2 , :],[1 ,1 ,- 1 ,- 1 ], 6 )
@@ -96,6 +96,35 @@ def test_no_cyc2(self):
9696 assert (grid == gridout ).all ()
9797
9898
99+ class TestShiftdata (TestCase ):
100+
101+ def test_2_points_should_work (self ):
102+ """
103+ Shiftdata should work with 2 points
104+ """
105+ bm = Basemap (llcrnrlon = 0 , llcrnrlat = - 80 , urcrnrlon = 360 , urcrnrlat = 80 , projection = 'mill' )
106+
107+ lons_expected = [10 , 15 , 20 ]
108+ lonsout = bm .shiftdata (lons_expected )
109+ assert_almost_equal (lons_expected , lonsout )
110+
111+ lonsout_expected = bm .shiftdata ([10 , 361 , 362 ])
112+ lonsout = bm .shiftdata ([10 , 361 ])
113+ assert_almost_equal (lonsout_expected [:len (lonsout )], lonsout )
114+
115+ def test_1_point_should_work (self ):
116+ bm = Basemap (llcrnrlon = 0 , llcrnrlat = - 80 , urcrnrlon = 360 , urcrnrlat = 80 , projection = 'mill' )
117+
118+ # should not fail
119+ lonsout = bm .shiftdata ([361 ])
120+ assert_almost_equal (lonsout , [1.0 ,])
121+
122+ lonsout = bm .shiftdata ([10 ])
123+ assert_almost_equal (lonsout , [10.0 ,])
124+
125+
126+
127+
99128def test ():
100129 """
101130 Run some tests.
0 commit comments