@@ -98,6 +98,13 @@ def test_no_cyc2(self):
9898
9999class TestShiftdata (TestCase ):
100100
101+ def _get_2d_lons (self , lons1d ):
102+ """
103+ Generate a 2d grid
104+ """
105+ lats = [10 , ] * len (lons1d )
106+ return np .meshgrid (lons1d , lats )[0 ]
107+
101108 def test_2_points_should_work (self ):
102109 """
103110 Shiftdata should work with 2 points
@@ -122,7 +129,24 @@ def test_1_point_should_work(self):
122129 lonsout = bm .shiftdata ([10 ])
123130 assert_almost_equal (lonsout , [10.0 ,])
124131
132+ lonsin = np .array ([361.0 ])
133+ lonsin .shape = (1 , 1 )
134+ lonsout = bm .shiftdata (lonsin )
135+ assert_almost_equal (lonsout .squeeze (), [1.0 ,])
136+
137+ def test_less_than_n_by_3_points_should_work (self ):
138+ bm = Basemap (llcrnrlon = 0 , llcrnrlat = - 80 , urcrnrlon = 360 , urcrnrlat = 80 , projection = 'mill' )
139+ lons_expected = self ._get_2d_lons ([10 , 15 , 20 ])
140+
141+ # nothing should change
142+ lonsout = bm .shiftdata (lons_expected )
143+ assert_almost_equal (lons_expected , lonsout )
125144
145+ # shift n x 3 and n x 2 grids and compare results over overlapping region
146+ lonsin = self ._get_2d_lons ([10 , 361 , 362 ])
147+ lonsout_expected = bm .shiftdata (lonsin )[:, :2 ]
148+ lonsout = bm .shiftdata (lonsin [:, :2 ])
149+ assert_almost_equal (lonsout_expected , lonsout )
126150
127151
128152def test ():
0 commit comments