@@ -334,6 +334,7 @@ def locate_label(self, linecontour, labelwidth):
334
334
part of the contour).
335
335
"""
336
336
337
+ # Number of contour points
337
338
nsize = len (linecontour )
338
339
if labelwidth > 1 :
339
340
xsize = int (np .ceil (nsize / labelwidth ))
@@ -353,7 +354,10 @@ def locate_label(self, linecontour, labelwidth):
353
354
xlast = XX [:, - 1 ].reshape (xsize , 1 )
354
355
s = (yfirst - YY ) * (xlast - xfirst ) - (xfirst - XX ) * (ylast - yfirst )
355
356
L = np .sqrt ((xlast - xfirst ) ** 2 + (ylast - yfirst ) ** 2 ).ravel ()
356
- dist = np .add .reduce (([(abs (s )[i ] / L [i ]) for i in range (xsize )]), - 1 )
357
+ # Ignore warning that divide by zero throws, as this is a valid option
358
+ with np .errstate (divide = 'ignore' , invalid = 'ignore' ):
359
+ dist = np .add .reduce ([(abs (s )[i ] / L [i ]) for i in range (xsize )],
360
+ - 1 )
357
361
x , y , ind = self .get_label_coords (dist , XX , YY , ysize , labelwidth )
358
362
359
363
# There must be a more efficient way...
@@ -448,7 +452,10 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):
448
452
449
453
# Round to integer values but keep as float
450
454
# To allow check against nan below
451
- I = [np .floor (I [0 ]), np .ceil (I [1 ])]
455
+ # Ignore nans here to avoid throwing an error on on Appveyor build
456
+ # (can possibly be removed when build uses numpy 1.13)
457
+ with np .errstate (invalid = 'ignore' ):
458
+ I = [np .floor (I [0 ]), np .ceil (I [1 ])]
452
459
453
460
# Actually break contours
454
461
if closed :
0 commit comments