@@ -38,7 +38,7 @@ def test_cylindrical(self):
38
38
def test_nan (self ):
39
39
B = Basemap ()
40
40
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.
42
42
u [1 ,1 ] = 0.
43
43
ru , rv = B .rotate_vector (u ,v , lon , lat )
44
44
assert not np .isnan (ru ).any ()
@@ -117,6 +117,27 @@ def _get_2d_lons(self, lons1d):
117
117
lats = [10 , ] * len (lons1d )
118
118
return np .meshgrid (lons1d , lats )[0 ]
119
119
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
+
120
141
def test_2_points_should_work (self ):
121
142
"""
122
143
Shiftdata should work with 2 points
@@ -160,7 +181,7 @@ def test_less_than_n_by_3_points_should_work(self):
160
181
lonsout = bm .shiftdata (lonsin [:, :2 ])
161
182
assert_almost_equal (lonsout_expected , lonsout )
162
183
163
- @skipIf (PY3 and LooseVersion (pyproj .__version__ ) <= LooseVersion ("1.9.4" ),
184
+ @skipIf (PY3 and LooseVersion (pyproj .__version__ ) <= LooseVersion ("1.9.4" ),
164
185
"Test skipped in Python 3.x with pyproj version 1.9.4 and below." )
165
186
class TestProjectCoords (TestCase ):
166
187
def get_data (self ):
@@ -224,7 +245,7 @@ def test():
224
245
import unittest
225
246
226
247
from mpl_toolkits .basemap .diagnostic import package_versions
227
-
248
+
228
249
if '--verbose' in sys .argv or '-v' in sys .argv :
229
250
pkg_vers = package_versions ()
230
251
print ('Basemaps installed package versions:' )
0 commit comments