Skip to content

Commit

Permalink
STYL: Fix flake8 errors
Browse files Browse the repository at this point in the history
Add ignores for 504 and 605 (new line after binary operator and invalid escape sequence, both were giving false positives)

Fix Regex match pattern errors (missing `r` prefix to the pattern strings).
  • Loading branch information
JoostJM committed Nov 12, 2018
1 parent c828b99 commit 3095f78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ ignore:
E701,
# .has_key() is deprecated, use 'in'
W601,
# line break after binary operator
W504,
# invalid escape sequence
W605,

select: C,E,W,F,I
# flake8-import-order
application-import-names: radiomics,testUtils
Expand Down
19 changes: 6 additions & 13 deletions labs/pyradiomics-dcm/pyradiomics-dcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ def prefix2codes(self, prefix):
"modifierValue": self.makePrivateCode("Exponent transformation")})

# parameterized processing operations
elif re.match("wavelet-([HL]{2,3})", prefix):
match = re.match("wavelet-([HL]{2,3})", prefix)
elif re.match(r"wavelet-([HL]{2,3})", prefix):
match = re.match(r"wavelet-([HL]{2,3})", prefix)
modifiers.append({"modifier": imageTransformationConcept,
"modifierValue": self.makePrivateCode("Wavelet transformation")})
modifiers.append({"modifier": self.makePrivateCode("Wavelet sub-band"),
"modifierValue": self.makePrivateCode(match.group(1))})

elif re.match("log-sigma-([\d]+)-([\d]+)-([a-z]+)", prefix):
match = re.match("log-sigma-([\d]+)-([\d]+)-([a-z]+)", prefix)
elif re.match(r"log-sigma-([\d]+)-([\d]+)-([a-z]+)", prefix):
match = re.match(r"log-sigma-([\d]+)-([\d]+)-([a-z]+)", prefix)

units = match.group(3)
if units == "mm":
Expand Down Expand Up @@ -286,11 +286,7 @@ def addMeasurement(
quantityCode)
return
except Exception as e:
scriptlogger.error(
"Exception checking for NaN: " +
str(e) +
" " +
value)
scriptlogger.error("Exception checking for NaN: %s %s", str(e), value)
return

measurement["value"] = '%E' % Decimal(value)
Expand Down Expand Up @@ -559,10 +555,7 @@ def main():
dcm = pydicom.read_file(outputSRTempFile)
shutil.move(
outputSRTempFile,
os.path.join(
args.outputDir,
dcm.SOPInstanceUID +
".dcm"))
os.path.join(args.outputDir, dcm.SOPInstanceUID + ".dcm"))
except BaseException:
scriptlogger.error("Failed to move output SR!")

Expand Down

0 comments on commit 3095f78

Please sign in to comment.