Skip to content

Commit ff50ec4

Browse files
committed
STYLE: Prefer python3.9+ syntax recommendations
```bash pip install pyupgrade git ls-files '*.py' \ | xargs pyupgrade --py39-plus \ --exit-zero-even-if-changed ```
1 parent 34a8dfd commit ff50ec4

32 files changed

+47
-64
lines changed

bin/DatasetHierarchyReader.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import print_function
3-
41
import collections
52
import glob
63
import os
74

85

9-
class DatasetHierarchyReader(object):
6+
class DatasetHierarchyReader:
107
def __init__(self, inputDatasetDirectory, filetype=".nrrd"):
118
self.inputDatasetDirectory = inputDatasetDirectory
129
self.filetype = filetype

bin/GenerateInputCSV_Datasethierarchy.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import print_function
2-
31
import csv
42
import os
53

bin/GenerateInputCSV_Filename.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import print_function
2-
31
import csv
42
import os
53

docs/conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# pyradiomics documentation build configuration file, created by
43
# sphinx-quickstart on Tue Jun 28 13:27:28 2016.
@@ -12,7 +11,6 @@
1211
# All configuration values have a default; values that are commented out
1312
# serve to show the default.
1413

15-
from __future__ import print_function
1614

1715
import sys
1816
import os

examples/batchProcessingWithPandas.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22

3-
from __future__ import print_function
43

54
import logging
65
import os

examples/batchprocessing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22

3-
from __future__ import print_function
43

54
import collections
65
import csv
@@ -43,7 +42,7 @@ def main():
4342

4443
flists = []
4544
try:
46-
with open(inputCSV, "r") as inFile:
45+
with open(inputCSV) as inFile:
4746
cr = csv.DictReader(inFile, lineterminator="\n")
4847
flists = [row for row in cr]
4948
except Exception:

examples/batchprocessing_parallel.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22

3-
from __future__ import print_function
43

54
from collections import OrderedDict
65
import csv
@@ -63,7 +62,7 @@
6362
# loggers.
6463
class info_filter(logging.Filter):
6564
def __init__(self, name):
66-
super(info_filter, self).__init__(name)
65+
super().__init__(name)
6766
self.level = logging.WARNING
6867

6968
def filter(self, record):
@@ -201,7 +200,7 @@ def _writeResults(featureVector):
201200
# Extract List of cases
202201
cases = []
203202
try:
204-
with open(INPUTCSV, "r") as inFile:
203+
with open(INPUTCSV) as inFile:
205204
cr = csv.DictReader(inFile, lineterminator="\n")
206205
cases = []
207206
for row_idx, row in enumerate(cr, start=1):

examples/helloFeatureClass.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22

3-
from __future__ import print_function
43

54
import numpy
65
import SimpleITK as sitk
@@ -169,7 +168,7 @@
169168
logFirstorderFeatures.enableAllFeatures()
170169
results = logFirstorderFeatures.execute()
171170
for key, val in results.items():
172-
laplacianFeatureName = "%s_%s" % (imageTypeName, key)
171+
laplacianFeatureName = "{}_{}".format(imageTypeName, key)
173172
print(" ", laplacianFeatureName, ":", val)
174173
#
175174
# Show FirstOrder features, calculated on a wavelet filtered image
@@ -187,5 +186,5 @@
187186
results = waveletFirstOrderFeaturs.execute()
188187
print("Calculated firstorder features with wavelet ", decompositionName)
189188
for key, val in results.items():
190-
waveletFeatureName = "%s_%s" % (str(decompositionName), key)
189+
waveletFeatureName = "{}_{}".format(str(decompositionName), key)
191190
print(" ", waveletFeatureName, ":", val)

examples/helloRadiomics.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22

3-
from __future__ import print_function
43

54
import logging
65

@@ -64,4 +63,4 @@
6463
featureVector = extractor.execute(imageName, maskName)
6564

6665
for featureName in featureVector.keys():
67-
print("Computed %s: %s" % (featureName, featureVector[featureName]))
66+
print("Computed {}: {}".format(featureName, featureVector[featureName]))

examples/helloRadiomicsWithSettings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22

3-
from __future__ import print_function
43

54
import logging
65
import os
@@ -58,4 +57,4 @@
5857
featureVector = extractor.execute(imageName, maskName)
5958

6059
for featureName in featureVector.keys():
61-
print("Computed %s: %s" % (featureName, featureVector[featureName]))
60+
print("Computed {}: {}".format(featureName, featureVector[featureName]))

0 commit comments

Comments
 (0)