File tree 1 file changed +10
-2
lines changed 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -1066,13 +1066,21 @@ def set_xy(self, xy):
1066
1066
----------
1067
1067
xy : (N, 2) array-like
1068
1068
The coordinates of the vertices.
1069
+
1070
+ Notes
1071
+ -----
1072
+ Unlike `~.path.Path`, we do not ignore the last input vertex. If the
1073
+ polygon is meant to be closed, and the last point of the polygon is not
1074
+ equal to the first, we assume that the user has not explicitly passed a
1075
+ ``CLOSEPOLY`` vertex, and add it ourselves.
1069
1076
"""
1070
1077
xy = np .asarray (xy )
1078
+ N , _ = xy .shape
1071
1079
if self ._closed :
1072
- if len ( xy ) and (xy [0 ] != xy [- 1 ]).any ():
1080
+ if N == 1 or N > 1 and (xy [0 ] != xy [- 1 ]).any ():
1073
1081
xy = np .concatenate ([xy , [xy [0 ]]])
1074
1082
else :
1075
- if len ( xy ) > 2 and (xy [0 ] == xy [- 1 ]).all ():
1083
+ if N > 2 and (xy [0 ] == xy [- 1 ]).all ():
1076
1084
xy = xy [:- 1 ]
1077
1085
self ._path = Path (xy , closed = self ._closed )
1078
1086
self .stale = True
You can’t perform that action at this time.
0 commit comments