Skip to content

Commit 3a7e320

Browse files
committed
python 3 compat
1 parent 05901e3 commit 3a7e320

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

gcodeplot.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ def align(self, plotter, xyMin, xyMax, align):
122122
def scalePoint(self, point):
123123
return (point[0]*self.scale[0]+self.offset[0], point[1]*self.scale[1]+self.offset[1])
124124

125-
def safeSorted(data,comparison=cmp):
125+
def comparison(a,b):
126+
return (a>b)-(a<b)
127+
128+
def safeSorted(data,comparison=comparison):
126129
"""
127130
A simpleminded recursive merge sort that will work even if the comparison function fails to be a partial order.
128131
Makes (shallow) copies of the data, which uses more memory than is absolutely necessary. In the intended application,
@@ -224,7 +227,7 @@ def nestedPaths(path1, path2):
224227
return 1
225228
x1 = sum(p.real for p in path1) / len(path1)
226229
x2 = sum(p.real for p in path2) / len(path2)
227-
return cmp(x1,x2)
230+
return comparison(x1,x2)
228231

229232
def removePenBob(data):
230233
"""

0 commit comments

Comments
 (0)