Skip to content

Commit 78a2536

Browse files
committed
Use floor division // on numpy arrays.
In Python 3.x this removes the DeprecationWarning for using a float for the index of numpy arrays. (Rolls back my previous commit changes.)
1 parent f37803f commit 78a2536

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

lib/mpl_toolkits/basemap/test.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,52 +57,52 @@ class TestShiftGrid(TestCase):
5757

5858
def make_data_cyc(self):
5959
loncyc = np.array([0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300,\
60-
330, 360], dtype=np.int)
60+
330, 360],dtype=np.float)
6161
gridcyc = np.array([[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,\
62-
11, 0]], dtype=np.int)
62+
11, 0]],dtype=np.float)
6363
lonoutcyc = np.array([-180, -150, -120, -90, -60, -30, 0, 30,60,90,\
64-
120, 150, 180], dtype=np.int)
64+
120, 150, 180],dtype=np.float)
6565
gridoutcyc = np.array([[ 6, 7, 8, 9, 10, 11, 0, 1, 2,3,\
66-
4, 5, 6]], dtype=np.int)
66+
4, 5, 6]],dtype=np.float)
6767
return loncyc, gridcyc, lonoutcyc, gridoutcyc
6868

6969
def make_data_nocyc(self):
7070
lonnocyc = np.array([0, 30, 60, 90, 120, 150, 180, 210, 240, 270,\
71-
300, 330], dtype=np.int)
71+
300, 330],dtype=np.float)
7272
gridnocyc = np.array([[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\
73-
10, 11]], dtype=np.int)
73+
10, 11]],dtype=np.float)
7474
lonoutnocyc = np.array([-180, -150, -120, -90, -60, -30, 0, 30, 60,\
75-
90, 120, 150], dtype=np.int)
75+
90, 120, 150],dtype=np.float)
7676
gridoutnocyc = np.array([[ 6, 7, 8, 9, 10, 11, 0, 1, 2,\
77-
3, 4, 5]], dtype=np.int)
77+
3, 4, 5]],dtype=np.float)
7878
return lonnocyc, gridnocyc, lonoutnocyc, gridoutnocyc
7979

8080
def make_data_nocyc2(self):
8181
lonnocyc2 = np.array([15, 45, 75, 105, 135, 165, 195, 225, 255, 285,\
82-
315, 345], dtype=np.int)
82+
315, 345],dtype=np.float)
8383
gridnocyc2 = np.array([[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\
84-
10, 11]], dtype=np.int)
84+
10, 11]],dtype=np.float)
8585
lonoutnocyc2 = np.array([-165, -135, -105, -75, -45, -15, 15,45,75,\
86-
105, 135, 165], dtype=np.int)
86+
105, 135, 165],dtype=np.float)
8787
gridoutnocyc2 = np.array([[ 6, 7, 8, 9, 10, 11, 0, 1, 2,\
88-
3, 4, 5]], dtype=np.int)
88+
3, 4, 5]],dtype=np.float)
8989
return lonnocyc2, gridnocyc2, lonoutnocyc2, gridoutnocyc2
9090

9191
def test_cyc(self):
9292
lonin, gridin, lonout, gridout = self.make_data_cyc()
93-
grid, lon = shiftgrid(lonin[len(lonin)/2], gridin, lonin, start=False)
93+
grid, lon = shiftgrid(lonin[len(lonin)//2], gridin, lonin, start=False)
9494
assert (lon==lonout).all()
9595
assert (grid==gridout).all()
9696

9797
def test_no_cyc(self):
9898
lonin, gridin, lonout, gridout = self.make_data_nocyc()
99-
grid, lon = shiftgrid(lonin[len(lonin)/2], gridin, lonin, start=False)
99+
grid, lon = shiftgrid(lonin[len(lonin)//2], gridin, lonin, start=False)
100100
assert (lon==lonout).all()
101101
assert (grid==gridout).all()
102102

103103
def test_no_cyc2(self):
104104
lonin, gridin, lonout, gridout = self.make_data_nocyc2()
105-
grid, lon = shiftgrid(lonin[len(lonin)/2], gridin, lonin, start=False)
105+
grid, lon = shiftgrid(lonin[len(lonin)//2], gridin, lonin, start=False)
106106
assert (lon==lonout).all()
107107
assert (grid==gridout).all()
108108

@@ -221,4 +221,3 @@ def test():
221221
print('{0}\n'.format(pkg_vers))
222222

223223
unittest.main()
224-

0 commit comments

Comments
 (0)