Skip to content

Float division patches #3289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/matplotlib/cbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_mlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_simplification.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_start_with_moveto():
decodebytes = base64.decodestring

verts = np.fromstring(decodebytes(data), dtype='<i4')
verts = verts.reshape((len(verts) / 2, 2))
verts = verts.reshape((len(verts) // 2, 2))
path = Path(verts)
segs = path.iter_segments(transforms.IdentityTransform(), clip=(0.0, 0.0, 100.0, 100.0))
segs = list(segs)
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tri/trirefine.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def _refine_triangulation_once(triangulation, ancestors=None):
# points
# hint: each apex is shared by 2 masked_triangles except the borders.
borders = np.sum(neighbors == -1)
added_pts = (3*ntri + borders) / 2
added_pts = (3*ntri + borders) // 2
refi_npts = npts + added_pts
refi_x = np.zeros(refi_npts)
refi_y = np.zeros(refi_npts)
Expand Down