chiark / gitweb /
Minor cleanup suggested by pycharm, which speeds up SF a tiny bit.
authordaid303 <daid303@gmail.com>
Tue, 8 Jan 2013 09:26:52 +0000 (10:26 +0100)
committerdaid303 <daid303@gmail.com>
Tue, 8 Jan 2013 09:26:52 +0000 (10:26 +0100)
16 files changed:
Cura/gui/projectPlanner.py
Cura/slice/cura_sf/fabmetheus_utilities/euclidean.py
Cura/slice/cura_sf/fabmetheus_utilities/gcodec.py
Cura/slice/cura_sf/fabmetheus_utilities/geometry/geometry_utilities/evaluate.py
Cura/slice/cura_sf/fabmetheus_utilities/geometry/manipulation_paths/overhang.py
Cura/slice/cura_sf/fabmetheus_utilities/geometry/manipulation_paths/segment.py
Cura/slice/cura_sf/fabmetheus_utilities/intercircle.py
Cura/slice/cura_sf/fabmetheus_utilities/settings.py
Cura/slice/cura_sf/fabmetheus_utilities/vector3.py
Cura/slice/cura_sf/fabmetheus_utilities/vector3index.py
Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/comb.py
Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dwindle.py
Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/fill.py
Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/joris.py
Cura/slice/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/raft.py
Cura/slice/cura_sf/skeinforge_application/skeinforge_utilities/skeinforge_profile.py

index 4ca569ccdbb5f88b34d78d798b3bf9e451c8ec4f..197e83dcf37d267ccd384a43b76f2a1b7ee256aa 100644 (file)
@@ -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)
index 56e7d10235d4a2c63f528aabf49b4008f731fb2f..09359fb094b21ad7e951a5809258eef2830eb310 100644 (file)
@@ -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)
index 38b357ce54220cc49b5ba85169900545164fa4a9..3fd2043184006b095d8c21099c8ff44c86879baf 100644 (file)
@@ -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.'
index 82273ce9e46f78b30233ae051a58851118bcd44f..cb2d356fd50e591dd4b334b2f923ee7ac01dedb1 100644 (file)
@@ -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):
index 83f4e7130dda25e7bc8845e92d0cd0dd7615ff80..d8c357f9a70d95c98d734859a2d41b0940fca27e 100644 (file)
@@ -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
index a0311bb5b45ceb3a97b9c6c6be5927c7222310e9..6a022b9847c39e9ecfedeb2a9e55e3dc8273757b 100644 (file)
@@ -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])
index 39d618f7bdd9264d641dfc7d9e96c1714e673209..132acc24a8bd86fb5660910e7f68dd35f10677fe 100644 (file)
@@ -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]
index 8087a9d039e454a70e6a8e6fae9a352583c3c0e4..df816e0107e1888abed787305f8e1534b0421e66 100644 (file)
@@ -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:
index 6ab8adcc973cf209f88c31dc9dbaf8f430763622..217534ffc8f46ebc76e0ab3aa9692492080559f2 100644 (file)
@@ -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']
 
index fda137974ecbb6595f30882f3d52794b0ce69030..57470bb009bcb15970ed8f467e6228456dd20caf 100644 (file)
@@ -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']
 
index 5e12e853dbbf89d855b350d77d4bce0687ac4100..a42a0dd6e97e595c7dd3e5e4ff825d41843c0605 100644 (file)
@@ -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)
index 1ba8ba59a33fe272882088201582a4a47395ad1e..88eff86cf6c1b36535207fc57745bf8989b14b85 100644 (file)
@@ -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
index cd3661644bb712eec3bef9e426d0b3f9fb3881a7..9d71753feaa5b0f3e056998efc59f86d7c6ef68c 100644 (file)
@@ -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
 
index d211cdbb9718751f09e1e34dd8a39e8094170fb6..33e40ba19057d35190a3ede7a06f98fd1b955566 100644 (file)
@@ -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.
index b4771d86d80adff5a1a31dbd41497b92cae07b72..1de1508e6ec60cd5f91ae70ed95080e27278b775 100644 (file)
@@ -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):
index 967b09801d91bba8341204b0baa20506927b599c..9d4a43a873e0e2c44901aff32b35aa54293d4ffa 100644 (file)
@@ -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')