Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cast to integer to get rid of numpy warning #3241

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

Merged
merged 11 commits into from
Aug 26, 2014
Prev Previous commit
Delay the cast to int in contour.py
This is to allow checking againt nan below
Thangs @argriffing
  • Loading branch information
jenshnielsen committed Jul 23, 2014
commit a7e673ddcdf46374566e1e1689a57cf3512b7de7
11 changes: 6 additions & 5 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,20 +474,21 @@ 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
I = [int(np.floor(I[0])), int(np.ceil(I[1]))]
# Round to integer values but keep as float
# To allow check against nan below
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