@@ -13,7 +13,7 @@ def make_array(self):
13
13
u = np .ones ((len (lat ), len (lon )))
14
14
v = np .zeros ((len (lat ), len (lon )))
15
15
return u ,v ,lat ,lon
16
-
16
+
17
17
def test_cylindrical (self ):
18
18
# Cylindrical case
19
19
B = Basemap ()
@@ -22,7 +22,7 @@ def test_cylindrical(self):
22
22
# Check that the vectors are identical.
23
23
assert_almost_equal (ru , u )
24
24
assert_almost_equal (rv , v )
25
-
25
+
26
26
def test_nan (self ):
27
27
B = Basemap ()
28
28
u ,v ,lat ,lon = self .make_array ()
@@ -32,12 +32,12 @@ def test_nan(self):
32
32
assert not np .isnan (ru ).any ()
33
33
assert_almost_equal (u , ru )
34
34
assert_almost_equal (v , rv )
35
-
35
+
36
36
def test_npstere (self ):
37
37
# NP Stereographic case
38
38
B = Basemap (projection = 'npstere' , boundinglat = 50. , lon_0 = 0. )
39
39
u ,v ,lat ,lon = self .make_array ()
40
- v = np .ones ((len (lat ), len (lon )))
40
+ v = np .ones ((len (lat ), len (lon )))
41
41
ru , rv = B .rotate_vector (u ,v , lon , lat )
42
42
assert_almost_equal (ru [2 , :],[1 ,- 1 ,- 1 ,1 ], 6 )
43
43
assert_almost_equal (rv [2 , :],[1 ,1 ,- 1 ,- 1 ], 6 )
@@ -96,6 +96,35 @@ def test_no_cyc2(self):
96
96
assert (grid == gridout ).all ()
97
97
98
98
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
+
99
128
def test ():
100
129
"""
101
130
Run some tests.
0 commit comments