Skip to content

Commit 3291538

Browse files
Leengitdzenanz
authored andcommitted
STYLE: Apply black Python formatting.
1 parent 701c8c2 commit 3291538

File tree

13 files changed

+162
-147
lines changed

13 files changed

+162
-147
lines changed

Examples/RegistrationITKv4/ImageRegistration5.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,7 @@
126126
)
127127
print(
128128
"Translation: %f, %f"
129-
% (
130-
initialParameters.GetElement(3),
131-
initialParameters.GetElement(4),
132-
)
129+
% (initialParameters.GetElement(3), initialParameters.GetElement(4))
133130
)
134131

135132

Modules/Core/Mesh/wrapping/test/itkMeshArrayPixelTypeTest.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
# Create Vector Container and Store values in it for each Point
3030
# For windows use itk.ULL
31-
if hasattr(itk.VectorContainer, 'ULAD'):
31+
if hasattr(itk.VectorContainer, "ULAD"):
3232
IdentifierType = itk.UL
3333
else:
3434
IdentifierType = itk.ULL
@@ -41,16 +41,16 @@
4141
pixel_data_reference.SetSize(PixelDataSize)
4242
pixel_data_reference.Fill(0)
4343
pixel_data_reference[0] = i
44-
pixel_data_reference[4] = i+4
44+
pixel_data_reference[4] = i + 4
4545

4646
# Set the point data container
4747
mesh.SetPointData(v)
4848

4949
assert mesh.GetPointData().Size() == NumberOfPoints
5050
assert mesh.GetPointData().ElementAt(0)[0] == 0
5151
assert mesh.GetPointData().ElementAt(0)[4] == 4
52-
assert mesh.GetPointData().ElementAt(2)[0] == 2+0
53-
assert mesh.GetPointData().ElementAt(2)[4] == 2+4
52+
assert mesh.GetPointData().ElementAt(2)[0] == 2 + 0
53+
assert mesh.GetPointData().ElementAt(2)[4] == 2 + 4
5454

5555
# resize the PixelDataSize to see if it can be altered succesfully
5656
PixelDataSize = 10
@@ -59,10 +59,10 @@
5959
pixel_data_reference.SetSize(PixelDataSize)
6060
pixel_data_reference.Fill(0)
6161
pixel_data_reference[0] = i
62-
pixel_data_reference[9] = i+10
62+
pixel_data_reference[9] = i + 10
6363

6464
assert mesh.GetPointData().Size() == NumberOfPoints
6565
assert mesh.GetPointData().ElementAt(0)[0] == 0
6666
assert mesh.GetPointData().ElementAt(0)[9] == 10
67-
assert mesh.GetPointData().ElementAt(2)[0] == 2+0
68-
assert mesh.GetPointData().ElementAt(2)[9] == 2+10
67+
assert mesh.GetPointData().ElementAt(2)[0] == 2 + 0
68+
assert mesh.GetPointData().ElementAt(2)[9] == 2 + 10

Modules/Filtering/ImageGrid/wrapping/test/ResampleImageFilterTest.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,7 @@
130130

131131
resample = itk.ResampleImageFilter[ImageType, ImageType].New()
132132
interpolator = itk.WindowedSincInterpolateImageFunction[
133-
ImageType,
134-
3,
135-
itk.HammingWindowFunction[
136-
3,
137-
],
133+
ImageType, 3, itk.HammingWindowFunction[3,]
138134
].New()
139135
resample.SetInterpolator(interpolator)
140136

Utilities/Doxygen/datetime.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
# Writes the date and time in RFC 2822 format to stdout
1818

19-
import time
19+
import time
2020
import sys
21-
sys.stdout.write(time.strftime('%a, %d %b %Y %H:%M:%S +0000', time.gmtime()))
21+
22+
sys.stdout.write(time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()))

Utilities/Maintenance/BuildHeaderTest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
"itkBSplineDeformableTransform.h", # deprecated
4949
"vtkCaptureScreen.h", # these includes require VTK
5050
"itkMultiThreader.h", # Compatibility file, it should not be used
51-
"itkEnableIf.h", # Compatibility file, it should not be used
52-
"itkIsSame.h", # Compatibility file, it should not be used
53-
"itkIsBaseOf.h", # Compatibility file, it should not be used
54-
"itkIsConvertible.h", # Compatibility file, it should not be used
51+
"itkEnableIf.h", # Compatibility file, it should not be used
52+
"itkIsSame.h", # Compatibility file, it should not be used
53+
"itkIsBaseOf.h", # Compatibility file, it should not be used
54+
"itkIsConvertible.h", # Compatibility file, it should not be used
5555
"itkViewImage.h", # Depends on VTK_RENDERING_BACKEND
5656
"QuickView.h", # Depends on VTK_RENDERING_BACKEND
5757
"itkBSplineDeformableTransformInitializer.h",

Wrapping/Generators/Python/Tests/PyImageFilterTest.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,26 @@
2020
import numpy as np
2121
import functools
2222

23-
input_image = itk.image_from_array(np.random.randint(0,255,size=(6,6), dtype=np.uint8))
23+
input_image = itk.image_from_array(
24+
np.random.randint(0, 255, size=(6, 6), dtype=np.uint8)
25+
)
26+
2427

2528
def constant_output(py_image_filter, constant=42):
2629
output = py_image_filter.GetOutput()
2730
output.SetBufferedRegion(output.GetRequestedRegion())
2831
output.Allocate()
2932
output.FillBuffer(constant)
3033

34+
3135
def constant_wrapper(f, constant=42):
3236
@functools.wraps(f)
3337
def wrapper(*args):
3438
return f(*args, constant=constant)
39+
3540
return wrapper
3641

42+
3743
py_filter = itk.PyImageFilter.New(input_image)
3844
py_filter.SetPyGenerateData(constant_output)
3945
py_filter.Update()
@@ -47,8 +53,9 @@ def wrapper(*args):
4753
assert np.all(np.asarray(output_image) == 10)
4854

4955
# Functional interface
50-
output_image = itk.py_image_filter(input_image,
51-
py_generate_data=constant_wrapper(constant_output, 7))
56+
output_image = itk.py_image_filter(
57+
input_image, py_generate_data=constant_wrapper(constant_output, 7)
58+
)
5259
assert np.all(np.asarray(output_image) == 7)
5360

5461
# PyGenerateInputRequestedRegion
@@ -58,6 +65,7 @@ class CheckCalled(object):
5865
def __call__(self, py_image_filter):
5966
self.called = True
6067

68+
6169
check_called = CheckCalled()
6270
assert check_called.called == False
6371

@@ -79,9 +87,10 @@ def __call__(self, py_image_filter):
7987
def enlarge_output_requested_region(py_image_filter, data):
8088
data.SetRequestedRegionToLargestPossibleRegion()
8189

90+
8291
py_filter = itk.PyImageFilter.New(input_image)
8392
py_filter.SetPyGenerateData(constant_output)
84-
requested_region = itk.ImageRegion[2]([2,2], [3,3])
93+
requested_region = itk.ImageRegion[2]([2, 2], [3, 3])
8594
py_filter.GetOutput().SetRequestedRegion(requested_region)
8695
py_filter.Update()
8796
region = py_filter.GetOutput().GetRequestedRegion()

Wrapping/Generators/Python/Tests/PythonTypeTest.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,7 @@ def create_and_test(t, create_method):
8383
except Exception as e:
8484
msg = (
8585
"%s, %s: wrong Python class name: %s. "
86-
"Exception while evaluating it: %s"
87-
% (
88-
t,
89-
actual_type,
90-
obj_type,
91-
e,
92-
)
86+
"Exception while evaluating it: %s" % (t, actual_type, obj_type, e)
9387
)
9488
wrongType = 1
9589
if wrongType:

Wrapping/Generators/Python/Tests/extras.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ def custom_callback(name, progress):
175175
image.SetDirection(rotation)
176176
serialize_deserialize = pickle.loads(pickle.dumps(image))
177177
# verify_input_information checks origin, spacing, direction consistency
178-
comparison = itk.comparison_image_filter(image, serialize_deserialize, verify_input_information=True)
178+
comparison = itk.comparison_image_filter(
179+
image, serialize_deserialize, verify_input_information=True
180+
)
179181
assert np.sum(comparison) == 0.0
180182

181183
# Make sure we can read unsigned short, unsigned int, and cast
@@ -416,11 +418,13 @@ def custom_callback(name, progress):
416418
# and make sure that the matrix hasn't changed.
417419
assert m_itk(0, 0) == 1
418420
# Test __repr__
419-
assert repr(m_itk) == "itkMatrixD33 ([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])"
421+
assert (
422+
repr(m_itk) == "itkMatrixD33 ([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])"
423+
)
420424
# Test __array__
421425
assert np.array_equal(np.asarray(m_itk), np.eye(3))
422426
# Test array like input
423-
arr3 = [[0., 0.], [0., 0.]]
427+
arr3 = [[0.0, 0.0], [0.0, 0.0]]
424428
m_itk = itk.matrix_from_array(arr3)
425429
m_itk.SetIdentity()
426430
# Test that the array like has not changed,...

Wrapping/Generators/Python/itk/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,22 @@ def _dedup(seq):
138138
# Check if the module installed its own init file and load it.
139139
# ITK Modules __init__.py must be renamed to __init_{module_name}__.py before packaging
140140
# the wheel to avoid overriding this file on installation.
141-
module_init_file = os.path.join(os.path.dirname(__file__), "__init_" + module.lower() + "__.py")
141+
module_init_file = os.path.join(
142+
os.path.dirname(__file__), "__init_" + module.lower() + "__.py"
143+
)
142144
if not os.path.isfile(module_init_file):
143145
continue
144146

145147
# Load the module definition from file path
146-
spec = importlib.util.spec_from_file_location(f"{module}.__init__", module_init_file)
148+
spec = importlib.util.spec_from_file_location(
149+
f"{module}.__init__", module_init_file
150+
)
147151

148152
# Import and execute the __init__ file (this call will add the module binaries to sys path)
149153
loaded_module = importlib.util.module_from_spec(spec)
150154
spec.loader.exec_module(loaded_module)
151155

156+
152157
# After 'lifting' external symbols into this itk namespace,
153158
# Now do the initialization, and conversion to LazyLoading if necessary
154159
_initialize_module()

Wrapping/Generators/Python/itk/support/base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ def itk_load_swig_module(name: str, namespace=None):
187187
template_feature.get_cpp_class_name(), swig_class
188188
)
189189
setattr(
190-
this_module,
191-
template_feature.get_python_class_name(),
192-
swig_class,
190+
this_module, template_feature.get_python_class_name(), swig_class
193191
)
194192
if namespace is not None:
195193
current_value = namespace.get(

0 commit comments

Comments
 (0)