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

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Deprecate is_closed_polygon
  • Loading branch information
dstansby committed Sep 21, 2017
commit c1fbf27ef15f68ebbd40630a95cdbf05129706c5
15 changes: 12 additions & 3 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):
hlw = lw / 2.0

# Check if closed and, if so, rotate contour so label is at edge
closed = mlab.is_closed_polygon(slc)
closed = _is_closed_polygon(slc)
if closed:
slc = np.r_[slc[ind:-1], slc[:ind + 1]]

Expand Down Expand Up @@ -646,7 +646,7 @@ def labels(self, inline, inline_spacing):
# zero in print_label and locate_label. Other than these
# functions, this is not necessary and should probably be
# eventually removed.
if mlab.is_closed_polygon(lc):
if _is_closed_polygon(lc):
slc = np.r_[slc0, slc0[1:2, :]]
else:
slc = slc0
Expand Down Expand Up @@ -707,6 +707,15 @@ def _find_closest_point_on_leg(p1, p2, p0):
return d, pc


def _is_closed_polygon(X):
"""
Tests whether first and last object in a sequence are the same. These are
presumably coordinates on a polygonal curve, in which case this function
tests if that curve is closed.
"""
return np.all(X[0] == X[-1])


def _find_closest_point_on_path(lc, point):
"""
lc: coordinates of vertices
Expand All @@ -721,7 +730,7 @@ def _find_closest_point_on_path(lc, point):
xcmin = None
legmin = (None, None)

closed = mlab.is_closed_polygon(lc)
closed = _is_closed_polygon(lc)

# build list of legs before and after this vertex
legs = []
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/mlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -3812,6 +3812,7 @@ def poly_between(x, ylower, yupper):
return x, y


@cbook.deprecated('2.2')
def is_closed_polygon(X):
"""
Tests whether first and last object in a sequence are the same. These are
Expand Down