@@ -38,7 +38,7 @@ def test_cylindrical(self):
3838 def test_nan (self ):
3939 B = Basemap ()
4040 u ,v ,lat ,lon = self .make_array ()
41- # Set one element to 0, so that the vector magnitude is 0.
41+ # Set one element to 0, so that the vector magnitude is 0.
4242 u [1 ,1 ] = 0.
4343 ru , rv = B .rotate_vector (u ,v , lon , lat )
4444 assert not np .isnan (ru ).any ()
@@ -117,6 +117,27 @@ def _get_2d_lons(self, lons1d):
117117 lats = [10 , ] * len (lons1d )
118118 return np .meshgrid (lons1d , lats )[0 ]
119119
120+ def test_non_monotonous_longitudes (self ):
121+ """
122+ when called for scatter, the longitudes passed to shiftdata are
123+ not necessarily monotonous...
124+ """
125+ lons = [179 , 180 , 180 , 0 , 290 , 10 , 320 , - 150 , 350 , - 250 , 250 ]
126+ bm = Basemap (lon_0 = 0 )
127+
128+ # before having several break points would cause the exception,
129+ # inside the shiftdata method called from scatter method.
130+ self .assertRaises (ValueError , bm .shiftdata , lons , fix_wrap_around = True )
131+
132+ lons_new = bm .shiftdata (lons , fix_wrap_around = False )
133+
134+ # Check if the modified longitudes are inside of the projection region
135+ for lon in lons_new :
136+ assert lon >= bm .projparms ["lon_0" ] - 180
137+ assert lon <= bm .projparms ["lon_0" ] + 180
138+
139+
140+
120141 def test_2_points_should_work (self ):
121142 """
122143 Shiftdata should work with 2 points
@@ -160,7 +181,7 @@ def test_less_than_n_by_3_points_should_work(self):
160181 lonsout = bm .shiftdata (lonsin [:, :2 ])
161182 assert_almost_equal (lonsout_expected , lonsout )
162183
163- @skipIf (PY3 and LooseVersion (pyproj .__version__ ) <= LooseVersion ("1.9.4" ),
184+ @skipIf (PY3 and LooseVersion (pyproj .__version__ ) <= LooseVersion ("1.9.4" ),
164185 "Test skipped in Python 3.x with pyproj version 1.9.4 and below." )
165186class TestProjectCoords (TestCase ):
166187 def get_data (self ):
@@ -224,7 +245,7 @@ def test():
224245 import unittest
225246
226247 from mpl_toolkits .basemap .diagnostic import package_versions
227-
248+
228249 if '--verbose' in sys .argv or '-v' in sys .argv :
229250 pkg_vers = package_versions ()
230251 print ('Basemaps installed package versions:' )
0 commit comments