Skip to content

Commit 0c56c35

Browse files
apply black style (#646)
* apply black * update code spell * add black to pipeline
1 parent 8ba3e00 commit 0c56c35

File tree

164 files changed

+3505
-2442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+3505
-2442
lines changed

.github/workflows/style.yml

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ jobs:
1919
run: |
2020
pip install -r requirements_style.txt --disable-pip-version-check
2121
22+
- name: black style
23+
run: |
24+
python -m black --check -l 120 .
25+
2226
- name: Codespell
2327
run: |
2428
make codespell

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Simple makefile to simplify repetitive build env management tasks under posix
22

33
CODESPELL_DIRS ?= ./pyaedt
4-
CODESPELL_SKIP ?= "*.pyc,*.aedt,*.xml,*.txt,*.gif,*.png,*.jpg,*.js,*.html,*.doctree,*.ttf,*.woff,*.woff2,*.eot,*.mp4,*.inv,*.pickle,*.ipynb,flycheck*,./.git/*,./.hypothesis/*,*.yml,./docs/build/*,./docs/images/*,./dist/*,*~,.hypothesis*,./docs/source/examples/*,*cover,*.dat,*.mac,\#*,PKG-INFO,*.mypy_cache/*,*.xml,*.aedt,*.svg"
4+
CODESPELL_SKIP ?= "*.pyc,*.aedt,*.xml,*.txt,*.gif,*.png,*.jpg,*.js,*.html,*.doctree,*.ttf,*.woff,*.woff2,*.eot,*.mp4,*.inv,*.pickle,*.ipynb,flycheck*,./.git/*,./.hypothesis/*,*.yml,./docs/build/*,./docs/images/*,./dist/*,*~,.hypothesis*,./pyaedt/third_party,./docs/source/examples/*,*cover,*.dat,*.mac,\#*,PKG-INFO,*.mypy_cache/*,*.xml,*.aedt,*.svg"
55
CODESPELL_IGNORE ?= "ignore_words.txt"
66

77
all: doctest flake8

_unittest/conftest.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,20 @@
5858
config = json.load(f)
5959
else:
6060
default_version = "2021.2"
61-
if inside_desktop and "oDesktop" in dir(sys.modules['__main__']):
62-
default_version = sys.modules['__main__'].oDesktop.GetVersion()[0:6]
63-
config = {"desktopVersion": default_version, "NonGraphical": False, "NewThread": True, "test_desktops": False,
64-
"build_machine": True, "skip_space_claim": False, "skip_circuits": False, "skip_edb": False,
65-
"skip_debug": False, "local": False}
61+
if inside_desktop and "oDesktop" in dir(sys.modules["__main__"]):
62+
default_version = sys.modules["__main__"].oDesktop.GetVersion()[0:6]
63+
config = {
64+
"desktopVersion": default_version,
65+
"NonGraphical": False,
66+
"NewThread": True,
67+
"test_desktops": False,
68+
"build_machine": True,
69+
"skip_space_claim": False,
70+
"skip_circuits": False,
71+
"skip_edb": False,
72+
"skip_debug": False,
73+
"local": False,
74+
}
6675

6776

6877
class BasisTest:
@@ -144,6 +153,7 @@ def clean_desktop(desktop_init):
144153
desktop_init.release_desktop(close_projects=True, close_on_exit=False)
145154
return desktop_init
146155

156+
147157
@pytest.fixture
148158
def hfss():
149159
"""Create a new Hfss project."""

_unittest/launch_desktop_tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ def run_desktop_tests():
5454
aedtapp.close_desktop()
5555

5656

57-
if __name__ == '__main__':
57+
if __name__ == "__main__":
5858
run_desktop_tests()

_unittest/test_00_EDB.py

+20-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
23
# Setup paths for module imports
34
import gc
45

@@ -46,8 +47,9 @@ def test_01_find_by_name(self):
4647
assert comp is not None
4748
pin = self.edbapp.core_components.get_pin_from_component("J1", pinName="1")
4849
assert pin is not False
49-
parameters = self.edbapp.core_padstack.get_pad_parameters(pin[0], "TOP",
50-
self.edbapp.core_padstack.pad_type.RegularPad)
50+
parameters = self.edbapp.core_padstack.get_pad_parameters(
51+
pin[0], "TOP", self.edbapp.core_padstack.pad_type.RegularPad
52+
)
5153
assert isinstance(parameters[1], list)
5254
assert isinstance(parameters[0], int)
5355

@@ -79,8 +81,10 @@ def test_04_get_stackup(self):
7981
assert len(stackup.layers) > 2
8082
assert self.edbapp.core_stackup.stackup_layers["TOP"]._builder
8183
assert self.edbapp.core_stackup.stackup_layers["TOP"].id
82-
assert isinstance(self.edbapp.core_stackup.stackup_layers["TOP"].layer_type, int) or str(
83-
type(self.edbapp.core_stackup.stackup_layers["TOP"].layer_type)) == "<type 'LayerType'>"
84+
assert (
85+
isinstance(self.edbapp.core_stackup.stackup_layers["TOP"].layer_type, int)
86+
or str(type(self.edbapp.core_stackup.stackup_layers["TOP"].layer_type)) == "<type 'LayerType'>"
87+
)
8488

8589
def test_05_get_signal_layers(self):
8690
signal_layers = self.edbapp.core_stackup.signal_layers
@@ -161,20 +165,20 @@ def test_17_components(self):
161165
assert self.edbapp.core_components.components["R1"].pinlist
162166
pinname = self.edbapp.core_components.components["R1"].pinlist[0].GetName()
163167
assert (
164-
self.edbapp.core_components.components["R1"].pins[pinname].lower_elevation
165-
== self.edbapp.core_components.components["R1"].lower_elevation
168+
self.edbapp.core_components.components["R1"].pins[pinname].lower_elevation
169+
== self.edbapp.core_components.components["R1"].lower_elevation
166170
)
167171
assert (
168-
self.edbapp.core_components.components["R1"].pins[pinname].placement_layer
169-
== self.edbapp.core_components.components["R1"].placement_layer
172+
self.edbapp.core_components.components["R1"].pins[pinname].placement_layer
173+
== self.edbapp.core_components.components["R1"].placement_layer
170174
)
171175
assert (
172-
self.edbapp.core_components.components["R1"].pins[pinname].upper_elevation
173-
== self.edbapp.core_components.components["R1"].upper_elevation
176+
self.edbapp.core_components.components["R1"].pins[pinname].upper_elevation
177+
== self.edbapp.core_components.components["R1"].upper_elevation
174178
)
175179
assert (
176-
self.edbapp.core_components.components["R1"].pins[pinname].top_bottom_association
177-
== self.edbapp.core_components.components["R1"].top_bottom_association
180+
self.edbapp.core_components.components["R1"].pins[pinname].top_bottom_association
181+
== self.edbapp.core_components.components["R1"].top_bottom_association
178182
)
179183
assert self.edbapp.core_components.components["R1"].pins[pinname].position
180184
assert self.edbapp.core_components.components["R1"].pins[pinname].rotation
@@ -258,8 +262,7 @@ def test_36_create_coax_port(self):
258262
def test_37_create_circuit_port(self):
259263
initial_len = len(self.edbapp.core_padstack.pingroups)
260264
assert (
261-
self.edbapp.core_siwave.create_circuit_port_on_net("U2A5", "V1P5_S3", "U2A5", "GND", 50,
262-
"test") == "test"
265+
self.edbapp.core_siwave.create_circuit_port_on_net("U2A5", "V1P5_S3", "U2A5", "GND", 50, "test") == "test"
263266
)
264267
p2 = self.edbapp.core_siwave.create_circuit_port_on_net("U2A5", "V3P3_S0", "U2A5", "GND", 50, "test")
265268
assert p2 != "test" and "test" in p2
@@ -517,17 +520,15 @@ def test_66_create_solder_ball_on_component(self):
517520
assert self.edbapp.core_components.set_solder_ball("U1A1")
518521

519522
def test_67_add_void(self):
520-
plane_shape = self.edbapp.core_primitives.Shape("rectangle", pointA=["-5mm", "-5mm"],
521-
pointB=["5mm", "5mm"])
523+
plane_shape = self.edbapp.core_primitives.Shape("rectangle", pointA=["-5mm", "-5mm"], pointB=["5mm", "5mm"])
522524
plane = self.edbapp.core_primitives.create_polygon(plane_shape, "TOP", net_name="GND")
523525

524526
path = self.edbapp.core_primitives.Shape("polygon", points=[["0", "0"], ["0", "1mm"]])
525-
void = self.edbapp.core_primitives.create_path(path, layer_name="TOP",
526-
width="0.1mm")
527+
void = self.edbapp.core_primitives.create_path(path, layer_name="TOP", width="0.1mm")
527528
assert self.edbapp.core_primitives.add_void(plane, void)
528529

529530
def test_68_flip_layer_stackup(self):
530531
assert self.edbapp.core_stackup.flip_stackup_and_apply_transform()
531532

532533
def test_69_create_solder_balls_on_component(self):
533-
assert self.edbapp.core_components.set_solder_ball("U2A5")
534+
assert self.edbapp.core_components.set_solder_ball("U2A5")

_unittest/test_01_Design.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def setup_class(self):
2323
with Scratch(scratch_path) as self.local_scratch:
2424
self.test_project = self.local_scratch.copyfile(example_project)
2525
self.aedtapp = Hfss(
26-
projectname=self.test_project, specified_version=desktop_version,
26+
projectname=self.test_project,
27+
specified_version=desktop_version,
2728
)
2829
# self.aedtapp.save_project()
2930
# self.cache = DesignCache(self.aedtapp)
@@ -205,7 +206,7 @@ def test_20_get_3dComponents_properties(self):
205206
props = self.aedtapp.get_components3d_vars("Dipole_Antenna_DM")
206207
assert len(props) == 3
207208

208-
@pytest.mark.skipif(os.name == "posix", reason= "Not needed in Linux.")
209+
@pytest.mark.skipif(os.name == "posix", reason="Not needed in Linux.")
209210
def test_21_generate_temp_project_directory(self):
210211
proj_dir1 = self.aedtapp.generate_temp_project_directory("Example")
211212
assert os.path.exists(proj_dir1)

_unittest/test_02_3D_modeler.py

+14-21
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,9 @@ def test_08_duplicate_along_line(self):
102102
@pyaedt_unittest_check_desktop_error
103103
def test_09_thicken_sheet(self):
104104
udp = self.aedtapp.modeler.Position(0, 0, 0)
105-
id5 = self.aedtapp.modeler.primitives.create_circle(
106-
self.aedtapp.PLANE.XY, udp, 10, name="sheet1"
107-
)
105+
id5 = self.aedtapp.modeler.primitives.create_circle(self.aedtapp.PLANE.XY, udp, 10, name="sheet1")
108106
udp = self.aedtapp.modeler.Position(100, 100, 100)
109-
id6 = self.aedtapp.modeler.primitives.create_circle(
110-
self.aedtapp.PLANE.XY, udp, 10, name="sheet2"
111-
)
107+
id6 = self.aedtapp.modeler.primitives.create_circle(self.aedtapp.PLANE.XY, udp, 10, name="sheet2")
112108
status = self.aedtapp.modeler.thicken_sheet(id5, 3)
113109
assert status
114110
status = self.aedtapp.modeler.automatic_thicken_sheets(id6, 3, False)
@@ -157,21 +153,15 @@ def test_19_clone(self):
157153

158154
def test_20_intersect(self):
159155
udp = [0, 0, 0]
160-
o1 = self.aedtapp.modeler.primitives.create_rectangle(
161-
self.aedtapp.PLANE.XY, udp, [5, 10], name="Rect1"
162-
)
163-
o2 = self.aedtapp.modeler.primitives.create_rectangle(
164-
self.aedtapp.PLANE.XY, udp, [3, 12], name="Rect2"
165-
)
156+
o1 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.XY, udp, [5, 10], name="Rect1")
157+
o2 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.XY, udp, [3, 12], name="Rect2")
166158
assert self.aedtapp.modeler.intersect([o1, o2])
167159

168160
def test_21_connect(self):
169161
udp = [0, 0, 0]
170162
id1 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.XY, udp, [5, 10])
171163
udp = self.aedtapp.modeler.Position(0, 0, 10)
172-
id2 = self.aedtapp.modeler.primitives.create_rectangle(
173-
self.aedtapp.PLANE.XY, udp, [-3, 10]
174-
)
164+
id2 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.XY, udp, [-3, 10])
175165
assert self.aedtapp.modeler.connect([id1, id2])
176166

177167
def test_22_translate(self):
@@ -339,16 +329,18 @@ def test_43_set_working_coordinate_system(self):
339329
self.aedtapp.modeler.set_working_coordinate_system("new1")
340330

341331
def test_44_sweep_around_axis(self):
342-
rect1 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.YZ, [0, 0, 0],
343-
[20, 20], "rectangle_to_split")
332+
rect1 = self.aedtapp.modeler.primitives.create_rectangle(
333+
self.aedtapp.PLANE.YZ, [0, 0, 0], [20, 20], "rectangle_to_split"
334+
)
344335
assert rect1.sweep_around_axis("Z", sweep_angle=360, draft_angle=0)
345336

346337
def test_45_sweep_along_path(self):
347338
udp1 = [0, 0, 0]
348339
udp2 = [5, 0, 0]
349340
path = self.aedtapp.modeler.primitives.create_polyline([udp1, udp2], name="Poly1")
350-
rect1 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.YZ, [0, 0, 0],
351-
[20, 20], "rectangle_to_sweep")
341+
rect1 = self.aedtapp.modeler.primitives.create_rectangle(
342+
self.aedtapp.PLANE.YZ, [0, 0, 0], [20, 20], "rectangle_to_sweep"
343+
)
352344
assert rect1.sweep_along_path(path)
353345

354346
def test_46_section_object(self):
@@ -358,8 +350,9 @@ def test_46_section_object(self):
358350

359351
def test_47_sweep_along_vector(self):
360352
sweep_vector = [5, 0, 0]
361-
rect1 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.YZ, [0, 0, 0],
362-
[20, 20], "rectangle_to_vector")
353+
rect1 = self.aedtapp.modeler.primitives.create_rectangle(
354+
self.aedtapp.PLANE.YZ, [0, 0, 0], [20, 20], "rectangle_to_vector"
355+
)
363356
assert rect1.sweep_along_vector(sweep_vector)
364357

365358
def test_48_coordinate_systems_parametric(self):

_unittest/test_03_Materials.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,14 @@ def test_09_non_linear_materials(self):
159159
assert app.materials["myMat"].permeability.value == [[0, 0], [1, 12], [10, 30]]
160160
assert app.materials["myMat"].permittivity.value == [[0, 0], [2, 12], [10, 30]]
161161
assert app.materials["myMat"].conductivity.value == [[0, 0], [3, 12], [10, 30]]
162-
assert app.materials["myMat"].permeability.type == 'nonlinear'
163-
assert app.materials["myMat"].conductivity.type == 'nonlinear'
164-
assert app.materials["myMat"].permittivity.type == 'nonlinear'
165-
assert app.materials["myMat"].permeability.bunit == 'tesla'
162+
assert app.materials["myMat"].permeability.type == "nonlinear"
163+
assert app.materials["myMat"].conductivity.type == "nonlinear"
164+
assert app.materials["myMat"].permittivity.type == "nonlinear"
165+
assert app.materials["myMat"].permeability.bunit == "tesla"
166166
mat2 = app.materials.add_material("myMat2")
167167
assert mat2.permeability.set_non_linear([[0, 0], [1, 12], [10, 30]])
168168
assert app.modeler.create_box([0, 0, 0], [10, 10, 10], matname="myMat2")
169169

170170
def test_10_add_material_sweep(self):
171171
assert self.aedtapp.materials.add_material_sweep(["copper3", "new_copper"], "sweep_copper")
172-
assert "sweep_copper" in list(self.aedtapp.materials.material_keys.keys())
172+
assert "sweep_copper" in list(self.aedtapp.materials.material_keys.keys())

_unittest/test_05_Mesh.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ def teardown_class(self):
3030
def test_assign_model_resolution(self):
3131
udp = self.aedtapp.modeler.Position(0, 0, 0)
3232
coax_dimension = 200
33-
o = self.aedtapp.modeler.primitives.create_cylinder(
34-
self.aedtapp.PLANE.XY, udp, 3, coax_dimension, 0, "inner"
35-
)
33+
o = self.aedtapp.modeler.primitives.create_cylinder(self.aedtapp.PLANE.XY, udp, 3, coax_dimension, 0, "inner")
3634
self.aedtapp.mesh.assign_model_resolution(o, 1e-4, "ModelRes1")
3735
assert "ModelRes1" in [i.name for i in self.aedtapp.mesh.meshoperations]
3836
mr2 = self.aedtapp.mesh.assign_model_resolution(o.faces[0], 1e-4, "ModelRes2")
@@ -41,9 +39,7 @@ def test_assign_model_resolution(self):
4139
def test_assign_surface_mesh(self):
4240
udp = self.aedtapp.modeler.Position(10, 10, 0)
4341
coax_dimension = 200
44-
o = self.aedtapp.modeler.primitives.create_cylinder(
45-
self.aedtapp.PLANE.XY, udp, 3, coax_dimension, 0, "surface"
46-
)
42+
o = self.aedtapp.modeler.primitives.create_cylinder(self.aedtapp.PLANE.XY, udp, 3, coax_dimension, 0, "surface")
4743
surface = self.aedtapp.mesh.assign_surface_mesh(o.id, 3, "Surface")
4844
assert "Surface" in [i.name for i in self.aedtapp.mesh.meshoperations]
4945
assert surface.props["SliderMeshSettings"] == 3

_unittest/test_07_Object3D.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def setup_class(self):
1818
test_projectfile = os.path.join(self.local_scratch.path, "test_object3d" + ".aedt")
1919
self.aedtapp = Hfss()
2020
self.aedtapp.save_project(project_file=test_projectfile)
21-
#self.prim = self.aedtapp.modeler
21+
# self.prim = self.aedtapp.modeler
2222

2323
def teardown_class(self):
2424
self.aedtapp._desktop.ClearMessages("", "", 3)

_unittest/test_09_VariableManager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def test_12_decompose_variable_value(self):
339339
assert decompose_variable_value("3.123456m") == (3.123456, "m")
340340
assert decompose_variable_value("3m") == (3, "m")
341341
assert decompose_variable_value("3") == (3, "")
342-
assert decompose_variable_value("3.") == (3., "")
342+
assert decompose_variable_value("3.") == (3.0, "")
343343
assert decompose_variable_value("3.123456m2") == (3.123456, "m2")
344344
assert decompose_variable_value("3.123456Nm-2") == (3.123456, "Nm-2")
345345
assert decompose_variable_value("3.123456kg2m2") == (3.123456, "kg2m2")

_unittest/test_12_PostProcessing.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@ def test_02_export_fields(self):
102102
vollist = ["NewObject_IJD39Q"]
103103
plot2 = self.aedtapp.post.create_fieldplot_volume(vollist, quantity_name2, setup_name, intrinsic)
104104

105-
self.aedtapp.post.export_field_image_with_view(plot2.name, plot2.plotFolder,
106-
os.path.join(self.local_scratch.path, "prova2.jpg"))
105+
self.aedtapp.post.export_field_image_with_view(
106+
plot2.name, plot2.plotFolder, os.path.join(self.local_scratch.path, "prova2.jpg")
107+
)
107108
assert os.path.exists(os.path.join(self.local_scratch.path, "prova2.jpg"))
108-
assert os.path.exists(plot2.export_image(os.path.join(self.local_scratch.path, "test_x.jpg"),
109-
orientation="top"))
109+
assert os.path.exists(
110+
plot2.export_image(os.path.join(self.local_scratch.path, "test_x.jpg"), orientation="top")
111+
)
110112

111113
def test_03_create_scattering(self):
112114
setup_name = "Setup1 : Sweep"
@@ -135,7 +137,7 @@ def test_03_get_solution_data(self):
135137
assert my_data.data_real(trace_names[0])
136138
assert my_data.data_magnitude(trace_names[0])
137139
assert my_data.export_data_to_csv(os.path.join(self.local_scratch.path, "output.csv"))
138-
assert os.path.exists(os.path.join( self.local_scratch.path, "output.csv"))
140+
assert os.path.exists(os.path.join(self.local_scratch.path, "output.csv"))
139141

140142
def test_04_export_touchstone(self):
141143
self.aedtapp.export_touchstone("Setup1", "Sweep", os.path.join(self.local_scratch.path, "Setup1_Sweep.S2p"))

_unittest/test_13_LoadAEDTFile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
def _write_jpg(design_info, scratch):
1414
"""writes the jpg Image64 property of the design info
1515
to a temporary file and returns the filename"""
16-
filename = os.path.join(scratch, design_info['DesignName'] + ".jpg")
16+
filename = os.path.join(scratch, design_info["DesignName"] + ".jpg")
1717
image_data_str = design_info["Image64"]
1818
with open(filename, "wb") as f:
1919
if sys.version_info.major == 2:
20-
bytes = bytes(image_data_str).decode('base64')
20+
bytes = bytes(image_data_str).decode("base64")
2121
else:
2222
bytes = base64.decodebytes(image_data_str.encode("ascii"))
2323
f.write(bytes)

0 commit comments

Comments
 (0)