diff --git a/lib/matplotlib/cbook.py b/lib/matplotlib/cbook.py index d0978fa46d92..1ff1191be3de 100644 --- a/lib/matplotlib/cbook.py +++ b/lib/matplotlib/cbook.py @@ -1734,10 +1734,10 @@ def get_siblings(self, a): def simple_linear_interpolation(a, steps): + steps = int(np.floor(steps)) if steps == 1: return a - steps = np.floor(steps) new_length = ((len(a) - 1) * steps) + 1 new_shape = list(a.shape) new_shape[0] = new_length @@ -1747,7 +1747,6 @@ def simple_linear_interpolation(a, steps): a0 = a[0:-1] a1 = a[1:] delta = ((a1 - a0) / steps) - steps = int(steps) for i in range(1, steps): result[i::steps] = delta * i + a0 result[steps::steps] = a1 diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py index 383978cbc44d..ff3514bf5cd9 100644 --- a/lib/matplotlib/contour.py +++ b/lib/matplotlib/contour.py @@ -474,20 +474,20 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5): xy2 = mlab.less_simple_linear_interpolation( pl, lc, [xi[1]]) - # Make integer + # Make floating point representations of integers, keeping nans. I = [np.floor(I[0]), np.ceil(I[1])] # Actually break contours if closed: # This will remove contour if shorter than label if np.all(~np.isnan(I)): - nlc.append(np.r_[xy2, lc[I[1]:I[0] + 1], xy1]) + nlc.append(np.r_[xy2, lc[int(I[1]):int(I[0]) + 1], xy1]) else: # These will remove pieces of contour if they have length zero if not np.isnan(I[0]): - nlc.append(np.r_[lc[:I[0] + 1], xy1]) + nlc.append(np.r_[lc[:int(I[0]) + 1], xy1]) if not np.isnan(I[1]): - nlc.append(np.r_[xy2, lc[I[1]:]]) + nlc.append(np.r_[xy2, lc[int(I[1]):]]) # The current implementation removes contours completely # covered by labels. Uncomment line below to keep diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 638e4907095a..6f89ac1d1349 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -523,7 +523,7 @@ def test_nonfinite_limits(): y = np.log(x) finally: np.seterr(**olderr) - x[len(x)/2] = np.nan + x[len(x) // 2] = np.nan fig = plt.figure() ax = fig.add_subplot(111) ax.plot(x, y) diff --git a/lib/matplotlib/tests/test_mlab.py b/lib/matplotlib/tests/test_mlab.py index 0cc991f05ebf..3dbf0dd54977 100644 --- a/lib/matplotlib/tests/test_mlab.py +++ b/lib/matplotlib/tests/test_mlab.py @@ -1325,8 +1325,8 @@ def createStim(self, fstims, iscomplex, sides, nsides, len_x=None, freqs_specgram = freqs_density # time points for specgram - t_start = NFFT_specgram_real/2 - t_stop = len(x) - NFFT_specgram_real/2+1 + t_start = NFFT_specgram_real // 2 + t_stop = len(x) - NFFT_specgram_real // 2 + 1 t_step = NFFT_specgram_real - nover_specgram_real t_specgram = x[t_start:t_stop:t_step] if NFFT_specgram_real % 2: diff --git a/lib/matplotlib/tests/test_simplification.py b/lib/matplotlib/tests/test_simplification.py index a1bc217bf6fd..e99ac097a989 100644 --- a/lib/matplotlib/tests/test_simplification.py +++ b/lib/matplotlib/tests/test_simplification.py @@ -153,7 +153,7 @@ def test_start_with_moveto(): decodebytes = base64.decodestring verts = np.fromstring(decodebytes(data), dtype='