Skip to content

Commit

Permalink
STYLE: Update python code with whitespace fixes
Browse files Browse the repository at this point in the history
This fixes all remaining pycodestyle E2 whitespace error codes.

Bulk of updates performed using autopep8 CLI
with the following command:

  autopep8 --in-place --select E201,E202,E203,E211,E221,E222,E225,E226,E227,E228,E231,E241,E251,E261,E262,E265,E266,E271 $(git ls-files '*.py')

See https://github.com/hhatto/autopep8#readme

References:

* Whitespace after '('
  See https://www.flake8rules.com/rules/E201.html

* Whitespace before ')'
  See https://www.flake8rules.com/rules/E202.html

* Whitespace before ':'
  See https://www.flake8rules.com/rules/E203.html

* Whitespace before '('
  See https://www.flake8rules.com/rules/E211.html

* Multiple spaces before operator
  See https://www.flake8rules.com/rules/E221.html

* Multiple spaces after operator
  See https://www.flake8rules.com/rules/E222.html

* Missing whitespace around operator
  See https://www.flake8rules.com/rules/E225.html

* Missing whitespace around arithmetic operator
  See https://www.flake8rules.com/rules/E226.html

* Missing whitespace around bitwise or shift operator
  See https://www.flake8rules.com/rules/E227.html

* Missing whitespace around modulo operator
  See https://www.flake8rules.com/rules/E228.html

* Missing whitespace after ',', ';', or ':'
  See https://www.flake8rules.com/rules/E231.html

* Multiple spaces after ','
  See https://www.flake8rules.com/rules/E241.html

* Unexpected spaces around keyword / parameter equals
  See https://www.flake8rules.com/rules/E251.html

* At least two spaces before inline comment
  See https://www.flake8rules.com/rules/E261.html

* Inline comment should start with '# '
  See https://www.flake8rules.com/rules/E262.html

* Block comment should start with '# '
  See https://www.flake8rules.com/rules/E265.html

* Too many leading '#' for block comment
  See https://www.flake8rules.com/rules/E266.html

* Multiple spaces after keyword
  See https://www.flake8rules.com/rules/E271.html
  • Loading branch information
jamesobutler authored and lassoan committed Jun 22, 2022
1 parent e8d195c commit 5b0fc5c
Show file tree
Hide file tree
Showing 177 changed files with 2,805 additions and 2,841 deletions.
36 changes: 0 additions & 36 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -70,42 +70,6 @@ ignore = \
E129, \
# continuation line unaligned for hanging indent
E131, \
# whitespace after '('
E201, \
# whitespace before ')'
E202, \
# whitespace before ','
E203, \
# whitespace before '('
E211, \
# multiple spaces before operator
E221, \
# multiple spaces after operator
E222, \
# missing whitespace around operator
E225, \
# missing whitespace around arithmetic operator
E226, \
# missing whitespace around bitwise or shift operator
E227, \
# missing whitespace around modulo operator
E228, \
# missing whitespace after ','
E231, \
# multiple spaces after ','
E241, \
# unexpected spaces around keyword / parameter equals
E251, \
# at least two spaces before inline comment
E261, \
# inline comment should start with '# '
E262, \
# block comment should start with '# '
E265, \
# too many leading '#' for block comment
E266, \
# multiple spaces after keyword
E271, \
# multiple imports on one line
E401, \
# module level import not at top of file
Expand Down
20 changes: 10 additions & 10 deletions Applications/SlicerApp/Testing/Python/AtlasTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class AtlasTests(ScriptedLoadableModule):

def __init__(self, parent):
ScriptedLoadableModule.__init__(self, parent)
parent.title = "AtlasTests" # TODO make this more human readable by adding spaces
parent.title = "AtlasTests" # TODO make this more human readable by adding spaces
parent.categories = ["Testing.TestCases"]
parent.dependencies = []
parent.contributors = ["Steve Pieper (Isomics)"] # replace with "Firstname Lastname (Org)"
parent.contributors = ["Steve Pieper (Isomics)"] # replace with "Firstname Lastname (Org)"
parent.helpText = """
This is a self test that downloads and displays volumetric atlases from the NA-MIC publication database.
Expand All @@ -33,7 +33,7 @@ def __init__(self, parent):
"""
parent.acknowledgementText = """
This file was originally developed by Steve Pieper, Isomics, Inc. and was partially funded by NIH grant 3P41RR013218-12S1.
""" # replace with organization, grant and thanks.
""" # replace with organization, grant and thanks.


#
Expand Down Expand Up @@ -105,7 +105,7 @@ class AtlasTestsLogic(ScriptedLoadableModuleLogic):
https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/ScriptedLoadableModule.py
"""

def hasImageData(self,volumeNode):
def hasImageData(self, volumeNode):
"""This is a dummy logic method that
returns true if the passed in volume
node has valid image data
Expand Down Expand Up @@ -161,7 +161,7 @@ def test_AbdominalAtlasTest(self):
'uris': TESTING_DATA_URL + 'SHA256/5d315abf7d303326669c6075f9eea927eeda2e531a5b1662cfa505806cb498ea',
'checksums': 'SHA256:5d315abf7d303326669c6075f9eea927eeda2e531a5b1662cfa505806cb498ea',
}
self.perform_AtlasTest(downloads,'I')
self.perform_AtlasTest(downloads, 'I')

def test_BrainAtlasTest(self):
self.delayDisplay('Running Brain Atlas Test')
Expand All @@ -171,7 +171,7 @@ def test_BrainAtlasTest(self):
'uris': TESTING_DATA_URL + 'SHA256/688ebcc6f45989795be2bcdc6b8b5bfc461f1656d677ed3ddef8c313532687f1',
'checksums': 'SHA256:688ebcc6f45989795be2bcdc6b8b5bfc461f1656d677ed3ddef8c313532687f1',
}
self.perform_AtlasTest(downloads,'A1_grayT1')
self.perform_AtlasTest(downloads, 'A1_grayT1')

def test_KneeAtlasTest(self):
self.delayDisplay('Running Knee Atlas Test')
Expand All @@ -181,7 +181,7 @@ def test_KneeAtlasTest(self):
'uris': TESTING_DATA_URL + 'SHA256/5d5506c07c238918d0c892e7b04c26ad7f43684d89580780bb207d1d860b0b33',
'checksums': 'SHA256:5d5506c07c238918d0c892e7b04c26ad7f43684d89580780bb207d1d860b0b33',
}
self.perform_AtlasTest(downloads,'I')
self.perform_AtlasTest(downloads, 'I')

def perform_AtlasTest(self, downloads, testVolumePattern):
""" Perform the actual atlas test.
Expand All @@ -201,7 +201,7 @@ def perform_AtlasTest(self, downloads, testVolumePattern):

volumeNode = slicer.util.getNode(pattern=testVolumePattern)
logic = AtlasTestsLogic()
self.assertIsNotNone( logic.hasImageData(volumeNode) )
self.assertIsNotNone(logic.hasImageData(volumeNode))

m = slicer.util.mainWindow()

Expand Down Expand Up @@ -236,7 +236,7 @@ def perform_AtlasTest(self, downloads, testVolumePattern):
# collapse and change the color on the hierarchy to full red
mh.SetExpanded(0)
self.delayDisplay("Model hierarchy " + mh.GetName() + ": expanded = false")
mhd.SetColor(1,0,0)
mhd.SetColor(1, 0, 0)
self.delayDisplay("Model hierarchy " + mh.GetName() + ": color = red")
# set the collapsed visibility to 0
mhd.SetVisibility(0)
Expand All @@ -257,7 +257,7 @@ def perform_AtlasTest(self, downloads, testVolumePattern):
numSceneViews = slicer.mrmlScene.GetNumberOfNodesByClass("vtkMRMLSceneViewNode")
for s in range(numSceneViews):
sv = slicer.mrmlScene.GetNthNodeByClass(s, "vtkMRMLSceneViewNode")
self.delayDisplay("Restoring scene " + sv.GetName() + " (" + str(s+1) + "/" + str(numSceneViews) + ")")
self.delayDisplay("Restoring scene " + sv.GetName() + " (" + str(s + 1) + "/" + str(numSceneViews) + ")")
sv.RestoreScene()

self.delayDisplay('Test passed!')
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, parent):
self.parent.title = "BRAINSFit Rigid Registration vtkITKTransformConverter crash (Issue 4139)"
self.parent.categories = ["Testing.TestCases"]
self.parent.dependencies = []
self.parent.contributors = ["Jean-Christophe Fillion-Robin (Kitware)"] # replace with "Firstname Lastname (Organization)"
self.parent.contributors = ["Jean-Christophe Fillion-Robin (Kitware)"] # replace with "Firstname Lastname (Organization)"
self.parent.helpText = """This test has been added to check that
Slicer does not crash in vtkITKTransformConverter after completing BRAINSFit rigid registration.
Expand All @@ -28,7 +28,7 @@ def __init__(self, parent):
self.parent.acknowledgementText = """
This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
and was partially funded by NIH grant 1U24CA194354-01.
""" # replace with organization, grant and thanks.
""" # replace with organization, grant and thanks.


#
Expand Down Expand Up @@ -58,7 +58,7 @@ class BRAINSFitRigidRegistrationCrashIssue4139Logic(ScriptedLoadableModuleLogic)
https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/ScriptedLoadableModule.py
"""

def hasImageData(self,volumeNode):
def hasImageData(self, volumeNode):
"""This is an example logic method that
returns true if the passed in volume
node has valid image data
Expand Down Expand Up @@ -123,11 +123,11 @@ def test_BRAINSFitRigidRegistrationCrashIssue4139(self):
slicer.mrmlScene.AddNode(outputVolume)

parameters = {
'fixedVolume' : fixed,
'movingVolume' : moving,
'linearTransform' : outputTransform,
'outputVolume' : outputVolume,
'useRigid' : True
'fixedVolume': fixed,
'movingVolume': moving,
'linearTransform': outputTransform,
'outputVolume': outputVolume,
'useRigid': True
}
cmdLineNode = slicer.cli.runSync(slicer.modules.brainsfit, parameters=parameters)
self.assertIsNotNone(cmdLineNode)
Expand Down
8 changes: 4 additions & 4 deletions Applications/SlicerApp/Testing/Python/CLIEventTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

class CLIEventTest(ScriptedLoadableModule):
def __init__(self, parent):
parent.title = "CLIEventTest" # TODO make this more human readable by adding spaces
parent.title = "CLIEventTest" # TODO make this more human readable by adding spaces
parent.categories = ["Testing.TestCases"]
parent.dependencies = ["CLI4Test"]
parent.contributors = ["Johan Andruejol (Kitware)"]
parent.helpText = """
This is a self test that tests that CLI send all the event properly.
"""
parent.acknowledgementText = """""" # replace with organization, grant and thanks.
parent.acknowledgementText = """""" # replace with organization, grant and thanks.
self.parent = parent

# Add this test to the SelfTest module's list for discovery when the module
Expand Down Expand Up @@ -65,7 +65,7 @@ def runCLI(self, cliModule, cliNode, parameters, wait_for_completion):
cliNode = slicer.cli.run(cliModule, cliNode, parameters, wait_for_completion)

def onCLIModified(self, cliNode, event):
print ("-- " + cliNode.GetStatusString() + ":" + cliNode.GetName())
print("-- " + cliNode.GetStatusString() + ":" + cliNode.GetName())
self.StatusEvents.append(cliNode.GetStatus())

if not cliNode.IsBusy():
Expand Down Expand Up @@ -237,7 +237,7 @@ def test_SubjectHierarchyReference(self):
self.assertEqual(shNode.GetItemParent(shNode.GetItemByDataNode(outputVolume)), shNode.GetSceneItemID())

self.delayDisplay('Run CLI module')
cliParams = {'InputVolume': inputVolume.GetID(), 'OutputVolume': outputVolume.GetID(), 'ThresholdValue' : 100, 'ThresholdType' : 'Above'}
cliParams = {'InputVolume': inputVolume.GetID(), 'OutputVolume': outputVolume.GetID(), 'ThresholdValue': 100, 'ThresholdType': 'Above'}
cliNode = slicer.cli.run(slicer.modules.thresholdscalarvolume, None, cliParams, wait_for_completion=True)

# After CLI execution is completed, output volume must be in the same folder as the referenced node
Expand Down
Loading

0 comments on commit 5b0fc5c

Please sign in to comment.