From: daid303 Date: Tue, 8 Jan 2013 09:26:52 +0000 (+0100) Subject: Minor cleanup suggested by pycharm, which speeds up SF a tiny bit. X-Git-Tag: 13.03~123 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=5338d4291940236f48f06d94ef2c729b0a1e5905;p=cura.git Minor cleanup suggested by pycharm, which speeds up SF a tiny bit. --- diff --git a/Cura/gui/projectPlanner.py b/Cura/gui/projectPlanner.py index 4ca569cc..197e83dc 100644 --- a/Cura/gui/projectPlanner.py +++ b/Cura/gui/projectPlanner.py @@ -468,7 +468,7 @@ class projectPlanner(wx.Frame): self.preview.Refresh() def OnMoveDown(self, e): - if self.selection == None: + if self.selection is None: return i = self.listbox.GetSelection() if i == len(self.list) - 1: @@ -479,7 +479,7 @@ class projectPlanner(wx.Frame): self.preview.Refresh() def OnCopy(self, e): - if self.selection == None: + if self.selection is None: return item = self.selection.clone() @@ -490,7 +490,7 @@ class projectPlanner(wx.Frame): self.preview.Refresh() def OnSetCustomProfile(self, e): - if self.selection == None: + if self.selection is None: return dlg=wx.FileDialog(self, "Select profile", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST) diff --git a/Cura/slice/cura_sf/fabmetheus_utilities/euclidean.py b/Cura/slice/cura_sf/fabmetheus_utilities/euclidean.py index 56e7d102..09359fb0 100644 --- a/Cura/slice/cura_sf/fabmetheus_utilities/euclidean.py +++ b/Cura/slice/cura_sf/fabmetheus_utilities/euclidean.py @@ -71,17 +71,17 @@ def addElementToPixelListFromPoint( element, pixelDictionary, point ): def addHorizontallyBoundedPoint(begin, center, end, horizontalBegin, horizontalEnd, path): 'Add point if it is within the horizontal bounds.' - if center.real >= horizontalEnd and center.real <= horizontalBegin: + if horizontalEnd <= center.real <= horizontalBegin: path.append(center) return if end != None: - if center.real > horizontalBegin and end.real <= horizontalBegin: + if center.real > horizontalBegin >= end.real: centerMinusEnd = center - end along = (center.real - horizontalBegin) / centerMinusEnd.real path.append(center - along * centerMinusEnd) return if begin != None: - if center.real < horizontalEnd and begin.real >= horizontalEnd: + if center.real < horizontalEnd <= begin.real: centerMinusBegin = center - begin along = (center.real - horizontalEnd) / centerMinusBegin.real path.append(center - along * centerMinusBegin) diff --git a/Cura/slice/cura_sf/fabmetheus_utilities/gcodec.py b/Cura/slice/cura_sf/fabmetheus_utilities/gcodec.py index 38b357ce..3fd20431 100644 --- a/Cura/slice/cura_sf/fabmetheus_utilities/gcodec.py +++ b/Cura/slice/cura_sf/fabmetheus_utilities/gcodec.py @@ -238,7 +238,7 @@ class BoundingRectangle(object): def isPointInside(self, point): 'Determine if the point is inside the bounding rectangle.' - return point.imag >= self.cornerMinimum.imag and point.imag <= self.cornerMaximum.imag and point.real >= self.cornerMinimum.real and point.real <= self.cornerMaximum.real + return self.cornerMinimum.imag <= point.imag <= self.cornerMaximum.imag and self.cornerMinimum.real <= point.real <= self.cornerMaximum.real def parseCorner(self, line): 'Parse a gcode line and use the location to update the bounding corners.' diff --git a/Cura/slice/cura_sf/fabmetheus_utilities/geometry/geometry_utilities/evaluate.py b/Cura/slice/cura_sf/fabmetheus_utilities/geometry/geometry_utilities/evaluate.py index 82273ce9..cb2d356f 100644 --- a/Cura/slice/cura_sf/fabmetheus_utilities/geometry/geometry_utilities/evaluate.py +++ b/Cura/slice/cura_sf/fabmetheus_utilities/geometry/geometry_utilities/evaluate.py @@ -1159,7 +1159,7 @@ class Evaluator(object): 'Determine if the keyIndex is in range.' if keyIndex == None: return False - return keyIndex >= -len(self.value) and keyIndex < len(self.value) + return -len(self.value) <= keyIndex < len(self.value) class EvaluatorAddition(Evaluator): diff --git a/Cura/slice/cura_sf/fabmetheus_utilities/geometry/manipulation_paths/overhang.py b/Cura/slice/cura_sf/fabmetheus_utilities/geometry/manipulation_paths/overhang.py index 83f4e713..d8c357f9 100644 --- a/Cura/slice/cura_sf/fabmetheus_utilities/geometry/manipulation_paths/overhang.py +++ b/Cura/slice/cura_sf/fabmetheus_utilities/geometry/manipulation_paths/overhang.py @@ -328,8 +328,8 @@ class OverhangWiddershinsLeft(object): beginComplex = rotatedLoop[pointIndex] endComplex = rotatedLoop[ (pointIndex + 1) % len( rotatedLoop ) ] xIntersection = euclidean.getXIntersectionIfExists( beginComplex, endComplex, rotatedPointComplex.imag ) - if xIntersection != None: - if xIntersection >= beginX and xIntersection < endX: + if xIntersection is not None: + if beginX <= xIntersection < endX: xIntersectionIndexList.append( euclidean.XIntersectionIndex( pointIndex, xIntersection ) ) self.closestXDistance = 987654321.0 self.closestXIntersectionIndex = None diff --git a/Cura/slice/cura_sf/fabmetheus_utilities/geometry/manipulation_paths/segment.py b/Cura/slice/cura_sf/fabmetheus_utilities/geometry/manipulation_paths/segment.py index a0311bb5..6a022b98 100644 --- a/Cura/slice/cura_sf/fabmetheus_utilities/geometry/manipulation_paths/segment.py +++ b/Cura/slice/cura_sf/fabmetheus_utilities/geometry/manipulation_paths/segment.py @@ -36,7 +36,7 @@ def getManipulatedPaths(close, elementNode, loop, prefix, sideLength): segmentLoop = [] startEnd = StartEnd(elementNode, len(loop), prefix) for pointIndex in xrange(len(loop)): - if pointIndex >= startEnd.start and pointIndex < startEnd.end: + if startEnd.start <= pointIndex < startEnd.end: segmentLoop += getSegmentPath(derivation.center, loop, path, pointIndex) else: segmentLoop.append(loop[pointIndex]) diff --git a/Cura/slice/cura_sf/fabmetheus_utilities/intercircle.py b/Cura/slice/cura_sf/fabmetheus_utilities/intercircle.py index 39d618f7..132acc24 100644 --- a/Cura/slice/cura_sf/fabmetheus_utilities/intercircle.py +++ b/Cura/slice/cura_sf/fabmetheus_utilities/intercircle.py @@ -541,7 +541,7 @@ def removeIntersection( loop ): y = behindRotated.imag xIntersection = euclidean.getXIntersectionIfExists( aheadRotated, aheadMidpointRotated, y ) if xIntersection != None: - if xIntersection > min( behindMidpointRotated.real, behindRotated.real ) and xIntersection < max( behindMidpointRotated.real, behindRotated.real ): + if min( behindMidpointRotated.real, behindRotated.real ) < xIntersection < max( behindMidpointRotated.real, behindRotated.real ): intersectionPoint = normalizedSegment * complex( xIntersection, y ) loop[ ( pointIndex + len( loop ) - 1 ) % len( loop ) ] = intersectionPoint del loop[pointIndex] diff --git a/Cura/slice/cura_sf/fabmetheus_utilities/settings.py b/Cura/slice/cura_sf/fabmetheus_utilities/settings.py index 8087a9d0..df816e01 100644 --- a/Cura/slice/cura_sf/fabmetheus_utilities/settings.py +++ b/Cura/slice/cura_sf/fabmetheus_utilities/settings.py @@ -531,7 +531,7 @@ class MenuButtonDisplay(object): valueFound = False for radio in self.radioList: if radio.name == value: - valueFound = True; + valueFound = True if valueFound: self.value = value for radio in self.radioList: diff --git a/Cura/slice/cura_sf/fabmetheus_utilities/vector3.py b/Cura/slice/cura_sf/fabmetheus_utilities/vector3.py index 6ab8adcc..217534ff 100644 --- a/Cura/slice/cura_sf/fabmetheus_utilities/vector3.py +++ b/Cura/slice/cura_sf/fabmetheus_utilities/vector3.py @@ -35,7 +35,7 @@ __date__ = '$Date: 2008/21/04 $' __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html' -class Vector3: +class Vector3(object): 'A three dimensional vector class.' __slots__ = ['x', 'y', 'z'] diff --git a/Cura/slice/cura_sf/fabmetheus_utilities/vector3index.py b/Cura/slice/cura_sf/fabmetheus_utilities/vector3index.py index fda13797..57470bb0 100644 --- a/Cura/slice/cura_sf/fabmetheus_utilities/vector3index.py +++ b/Cura/slice/cura_sf/fabmetheus_utilities/vector3index.py @@ -35,7 +35,7 @@ __date__ = '$Date: 2008/21/04 $' __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html' -class Vector3Index: +class Vector3Index(object): 'A three dimensional vector index class.' __slots__ = ['index', 'x', 'y', 'z'] diff --git a/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/comb.py b/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/comb.py index 5e12e853..a42a0dd6 100644 --- a/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/comb.py +++ b/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/comb.py @@ -278,7 +278,7 @@ class CombSkein(object): maximumX = max(beginRotated.real, endRotated.real) minimumX = min(beginRotated.real, endRotated.real) for xIntersection in switchX: - if xIntersection.x > minimumX and xIntersection.x < maximumX: + if minimumX < xIntersection.x < maximumX: point = segment * complex(xIntersection.x, y) points.append(point) boundaryIndexes.append(xIntersection.index) diff --git a/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dwindle.py b/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dwindle.py index 1ba8ba59..88eff86c 100644 --- a/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dwindle.py +++ b/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dwindle.py @@ -241,7 +241,7 @@ class ThreadSection(object): rateMultiplier = self.dwindlePortionEnd * alongBetween + self.dwindlePortionBegin * (1.0 - alongBetween) self.addGcodeMovementByRate(distanceFeedRate, endRateMultiplier, location, rateMultiplier, slowdownFlowRateMultiplier) return - if self.dwindlePortionBegin > 1.0 and self.dwindlePortionEnd < 1.0: + if self.dwindlePortionBegin > 1.0 > self.dwindlePortionEnd: alongDwindle = 0.0 if self.dwindlePortionBegin > 1.0 + halfOverSteps: alongDwindle = (self.dwindlePortionBegin - 1.0) / dwindleDifference diff --git a/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/fill.py b/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/fill.py index cd366164..9d71753f 100644 --- a/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/fill.py +++ b/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/fill.py @@ -563,7 +563,7 @@ def insertGridPointPairWithLinePath( gridPoint, gridPointInsetX, gridPoints, isJ def isAddedPointOnPathFree( path, pixelTable, point, pointIndex, width ): 'Determine if the point added to a path is intersecting the pixel table or the path.' - if pointIndex > 0 and pointIndex < len(path): + if 0 < pointIndex < len(path): if isSharpCorner( ( path[pointIndex - 1] ), point, ( path[pointIndex] ) ): return False pointIndexMinusOne = pointIndex - 1 @@ -1232,7 +1232,7 @@ class FillSkein(object): if isSegmentCompletelyInAnIntersection(lineSegment, surroundingXIntersections ): xFirst = lineSegment[0].point.real xSecond = lineSegment[1].point.real - if gridPoint.real > min(xFirst, xSecond) and gridPoint.real < max(xFirst, xSecond): + if min(xFirst, xSecond) < gridPoint.real < max(xFirst, xSecond): return True return False diff --git a/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/joris.py b/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/joris.py index d211cdbb..33e40ba1 100644 --- a/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/joris.py +++ b/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/joris.py @@ -155,13 +155,13 @@ class JorisSkein(object): def addJorisedPerimeter(self): 'Add jorised perimeter.' - if self.perimeter == None: + if self.perimeter is None: return #Calculate the total length of the perimeter. p = self.oldLocation.dropAxis() - perimeterLength = 0; + perimeterLength = 0 for point in self.perimeter: - perimeterLength += abs( point - p ); + perimeterLength += abs( point - p ) p = point #Build the perimeter with an increasing Z over the length. diff --git a/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/raft.py b/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/raft.py index b4771d86..1de1508e 100644 --- a/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/raft.py +++ b/Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/raft.py @@ -322,7 +322,7 @@ def getVerticalEndpoints(horizontalSegmentsTable, horizontalStep, verticalOverha def setExtendedPoint( lineSegmentEnd, pointOriginal, x ): 'Set the point in the extended line segment.' - if x > min( lineSegmentEnd.point.real, pointOriginal.real ) and x < max( lineSegmentEnd.point.real, pointOriginal.real ): + if min( lineSegmentEnd.point.real, pointOriginal.real ) < x < max( lineSegmentEnd.point.real, pointOriginal.real ): lineSegmentEnd.point = complex( x, pointOriginal.imag ) def writeOutput(fileName, shouldAnalyze=True): diff --git a/Cura/slice/cura_sf/skeinforge_application/skeinforge_utilities/skeinforge_profile.py b/Cura/slice/cura_sf/skeinforge_application/skeinforge_utilities/skeinforge_profile.py index 967b0980..9d4a43a8 100644 --- a/Cura/slice/cura_sf/skeinforge_application/skeinforge_utilities/skeinforge_profile.py +++ b/Cura/slice/cura_sf/skeinforge_application/skeinforge_utilities/skeinforge_profile.py @@ -16,18 +16,18 @@ def getProfileName(craftTypeName): return 'Cura profile:' + craftTypeName def addListsToCraftTypeRepository(fileNameHelp, repository): - #print('addListsToCraftTypeRepository:', fileNameHelp, repository) - repository.name = fileNameHelp.split('.')[-2] - repository.preferences = [] + #print('addListsToCraftTypeRepository:', fileNameHelp, repository) + repository.name = fileNameHelp.split('.')[-2] + repository.preferences = [] def getCraftTypePluginModule( craftTypeName = ''): - "Get the craft type plugin module" - if craftTypeName == '': - craftTypeName = getCraftTypeName() - profilePluginsDirectoryPath = getPluginsDirectoryPath() - return archive.getModuleWithDirectoryPath( profilePluginsDirectoryPath, craftTypeName ) + "Get the craft type plugin module" + if craftTypeName == '': + craftTypeName = getCraftTypeName() + profilePluginsDirectoryPath = getPluginsDirectoryPath() + return archive.getModuleWithDirectoryPath( profilePluginsDirectoryPath, craftTypeName ) def getPluginsDirectoryPath(): - "Get the plugins directory path." - return archive.getSkeinforgePluginsPath('profile_plugins') + "Get the plugins directory path." + return archive.getSkeinforgePluginsPath('profile_plugins')