Skip to content

Commit

Permalink
Merge branch 'main' into release/0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcapodi78 committed Dec 22, 2021
2 parents 82c36e7 + dabb6c4 commit f1df886
Show file tree
Hide file tree
Showing 195 changed files with 6,993 additions and 3,099 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[run]
omit = examples/**/*, doc/**/*, testvenv/Lib/**/*, third_party/**/*
omit = examples/**/*, doc/**/*, testvenv/Lib/**/*, third_party/**/*, generic/toolkit.py
4 changes: 4 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
run: |
pip install -r requirements_style.txt --disable-pip-version-check
- name: black style
run: |
python -m black --check -l 120 .
- name: Codespell
run: |
make codespell
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Simple makefile to simplify repetitive build env management tasks under posix

CODESPELL_DIRS ?= ./pyaedt
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"
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"
CODESPELL_IGNORE ?= "ignore_words.txt"

all: doctest flake8
Expand Down
20 changes: 15 additions & 5 deletions _unittest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,20 @@
config = json.load(f)
else:
default_version = "2021.2"
if inside_desktop and "oDesktop" in dir(sys.modules['__main__']):
default_version = sys.modules['__main__'].oDesktop.GetVersion()[0:6]
config = {"desktopVersion": default_version, "NonGraphical": False, "NewThread": True, "test_desktops": False,
"build_machine": True, "skip_space_claim": False, "skip_circuits": False, "skip_edb": False,
"skip_debug": False, "local": False}
if inside_desktop and "oDesktop" in dir(sys.modules["__main__"]):
default_version = sys.modules["__main__"].oDesktop.GetVersion()[0:6]
config = {
"desktopVersion": default_version,
"NonGraphical": False,
"NewThread": True,
"test_desktops": False,
"build_machine": True,
"skip_space_claim": False,
"skip_circuits": False,
"skip_edb": False,
"skip_debug": False,
"local": False,
}


class BasisTest:
Expand Down Expand Up @@ -144,6 +153,7 @@ def clean_desktop(desktop_init):
desktop_init.release_desktop(close_projects=True, close_on_exit=False)
return desktop_init


@pytest.fixture
def hfss():
"""Create a new Hfss project."""
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion _unittest/launch_desktop_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ def run_desktop_tests():
aedtapp.close_desktop()


if __name__ == '__main__':
if __name__ == "__main__":
run_desktop_tests()
50 changes: 30 additions & 20 deletions _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os

# Setup paths for module imports
import gc

Expand All @@ -9,7 +10,7 @@

test_project_name = "Galileo_edb"
bom_example = "bom_example.csv"
from _unittest.conftest import config, desktop_version, local_path, scratch_path
from _unittest.conftest import config, desktop_version, local_path, scratch_path, is_ironpython

try:
import pytest
Expand Down Expand Up @@ -46,8 +47,9 @@ def test_01_find_by_name(self):
assert comp is not None
pin = self.edbapp.core_components.get_pin_from_component("J1", pinName="1")
assert pin is not False
parameters = self.edbapp.core_padstack.get_pad_parameters(pin[0], "TOP",
self.edbapp.core_padstack.pad_type.RegularPad)
parameters = self.edbapp.core_padstack.get_pad_parameters(
pin[0], "TOP", self.edbapp.core_padstack.pad_type.RegularPad
)
assert isinstance(parameters[1], list)
assert isinstance(parameters[0], int)

Expand Down Expand Up @@ -79,8 +81,10 @@ def test_04_get_stackup(self):
assert len(stackup.layers) > 2
assert self.edbapp.core_stackup.stackup_layers["TOP"]._builder
assert self.edbapp.core_stackup.stackup_layers["TOP"].id
assert isinstance(self.edbapp.core_stackup.stackup_layers["TOP"].layer_type, int) or str(
type(self.edbapp.core_stackup.stackup_layers["TOP"].layer_type)) == "<type 'LayerType'>"
assert (
isinstance(self.edbapp.core_stackup.stackup_layers["TOP"].layer_type, int)
or str(type(self.edbapp.core_stackup.stackup_layers["TOP"].layer_type)) == "<type 'LayerType'>"
)

def test_05_get_signal_layers(self):
signal_layers = self.edbapp.core_stackup.signal_layers
Expand Down Expand Up @@ -161,20 +165,20 @@ def test_17_components(self):
assert self.edbapp.core_components.components["R1"].pinlist
pinname = self.edbapp.core_components.components["R1"].pinlist[0].GetName()
assert (
self.edbapp.core_components.components["R1"].pins[pinname].lower_elevation
== self.edbapp.core_components.components["R1"].lower_elevation
self.edbapp.core_components.components["R1"].pins[pinname].lower_elevation
== self.edbapp.core_components.components["R1"].lower_elevation
)
assert (
self.edbapp.core_components.components["R1"].pins[pinname].placement_layer
== self.edbapp.core_components.components["R1"].placement_layer
self.edbapp.core_components.components["R1"].pins[pinname].placement_layer
== self.edbapp.core_components.components["R1"].placement_layer
)
assert (
self.edbapp.core_components.components["R1"].pins[pinname].upper_elevation
== self.edbapp.core_components.components["R1"].upper_elevation
self.edbapp.core_components.components["R1"].pins[pinname].upper_elevation
== self.edbapp.core_components.components["R1"].upper_elevation
)
assert (
self.edbapp.core_components.components["R1"].pins[pinname].top_bottom_association
== self.edbapp.core_components.components["R1"].top_bottom_association
self.edbapp.core_components.components["R1"].pins[pinname].top_bottom_association
== self.edbapp.core_components.components["R1"].top_bottom_association
)
assert self.edbapp.core_components.components["R1"].pins[pinname].position
assert self.edbapp.core_components.components["R1"].pins[pinname].rotation
Expand Down Expand Up @@ -258,8 +262,7 @@ def test_36_create_coax_port(self):
def test_37_create_circuit_port(self):
initial_len = len(self.edbapp.core_padstack.pingroups)
assert (
self.edbapp.core_siwave.create_circuit_port_on_net("U2A5", "V1P5_S3", "U2A5", "GND", 50,
"test") == "test"
self.edbapp.core_siwave.create_circuit_port_on_net("U2A5", "V1P5_S3", "U2A5", "GND", 50, "test") == "test"
)
p2 = self.edbapp.core_siwave.create_circuit_port_on_net("U2A5", "V3P3_S0", "U2A5", "GND", 50, "test")
assert p2 != "test" and "test" in p2
Expand Down Expand Up @@ -517,17 +520,24 @@ def test_66_create_solder_ball_on_component(self):
assert self.edbapp.core_components.set_solder_ball("U1A1")

def test_67_add_void(self):
plane_shape = self.edbapp.core_primitives.Shape("rectangle", pointA=["-5mm", "-5mm"],
pointB=["5mm", "5mm"])
plane_shape = self.edbapp.core_primitives.Shape("rectangle", pointA=["-5mm", "-5mm"], pointB=["5mm", "5mm"])
plane = self.edbapp.core_primitives.create_polygon(plane_shape, "TOP", net_name="GND")

path = self.edbapp.core_primitives.Shape("polygon", points=[["0", "0"], ["0", "1mm"]])
void = self.edbapp.core_primitives.create_path(path, layer_name="TOP",
width="0.1mm")
void = self.edbapp.core_primitives.create_path(path, layer_name="TOP", width="0.1mm")
assert self.edbapp.core_primitives.add_void(plane, void)

def test_68_flip_layer_stackup(self):
assert self.edbapp.core_stackup.flip_stackup_and_apply_transform()

def test_69_create_solder_balls_on_component(self):
assert self.edbapp.core_components.set_solder_ball("U2A5")
assert self.edbapp.core_components.set_solder_ball("U2A5")

@pytest.mark.skipif(is_ironpython, reason="This Test uses Ironpython")
def test_70_plot_on_matplotlib(self):
local_png = os.path.join(self.local_scratch.path, "test.png")
self.edbapp.core_nets.plot(None, None, save_plot=local_png)
assert os.path.exists(local_png)

def test_71_fix_circle_voids(self):
assert self.edbapp.core_primitives.fix_circle_void_for_clipping()
5 changes: 3 additions & 2 deletions _unittest/test_01_Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def setup_class(self):
with Scratch(scratch_path) as self.local_scratch:
self.test_project = self.local_scratch.copyfile(example_project)
self.aedtapp = Hfss(
projectname=self.test_project, specified_version=desktop_version,
projectname=self.test_project,
specified_version=desktop_version,
)
# self.aedtapp.save_project()
# self.cache = DesignCache(self.aedtapp)
Expand Down Expand Up @@ -205,7 +206,7 @@ def test_20_get_3dComponents_properties(self):
props = self.aedtapp.get_components3d_vars("Dipole_Antenna_DM")
assert len(props) == 3

@pytest.mark.skipif(os.name == "posix", reason= "Not needed in Linux.")
@pytest.mark.skipif(os.name == "posix", reason="Not needed in Linux.")
def test_21_generate_temp_project_directory(self):
proj_dir1 = self.aedtapp.generate_temp_project_directory("Example")
assert os.path.exists(proj_dir1)
Expand Down
35 changes: 14 additions & 21 deletions _unittest/test_02_3D_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,9 @@ def test_08_duplicate_along_line(self):
@pyaedt_unittest_check_desktop_error
def test_09_thicken_sheet(self):
udp = self.aedtapp.modeler.Position(0, 0, 0)
id5 = self.aedtapp.modeler.primitives.create_circle(
self.aedtapp.PLANE.XY, udp, 10, name="sheet1"
)
id5 = self.aedtapp.modeler.primitives.create_circle(self.aedtapp.PLANE.XY, udp, 10, name="sheet1")
udp = self.aedtapp.modeler.Position(100, 100, 100)
id6 = self.aedtapp.modeler.primitives.create_circle(
self.aedtapp.PLANE.XY, udp, 10, name="sheet2"
)
id6 = self.aedtapp.modeler.primitives.create_circle(self.aedtapp.PLANE.XY, udp, 10, name="sheet2")
status = self.aedtapp.modeler.thicken_sheet(id5, 3)
assert status
status = self.aedtapp.modeler.automatic_thicken_sheets(id6, 3, False)
Expand Down Expand Up @@ -157,21 +153,15 @@ def test_19_clone(self):

def test_20_intersect(self):
udp = [0, 0, 0]
o1 = self.aedtapp.modeler.primitives.create_rectangle(
self.aedtapp.PLANE.XY, udp, [5, 10], name="Rect1"
)
o2 = self.aedtapp.modeler.primitives.create_rectangle(
self.aedtapp.PLANE.XY, udp, [3, 12], name="Rect2"
)
o1 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.XY, udp, [5, 10], name="Rect1")
o2 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.XY, udp, [3, 12], name="Rect2")
assert self.aedtapp.modeler.intersect([o1, o2])

def test_21_connect(self):
udp = [0, 0, 0]
id1 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.XY, udp, [5, 10])
udp = self.aedtapp.modeler.Position(0, 0, 10)
id2 = self.aedtapp.modeler.primitives.create_rectangle(
self.aedtapp.PLANE.XY, udp, [-3, 10]
)
id2 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.XY, udp, [-3, 10])
assert self.aedtapp.modeler.connect([id1, id2])

def test_22_translate(self):
Expand Down Expand Up @@ -339,16 +329,18 @@ def test_43_set_working_coordinate_system(self):
self.aedtapp.modeler.set_working_coordinate_system("new1")

def test_44_sweep_around_axis(self):
rect1 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.YZ, [0, 0, 0],
[20, 20], "rectangle_to_split")
rect1 = self.aedtapp.modeler.primitives.create_rectangle(
self.aedtapp.PLANE.YZ, [0, 0, 0], [20, 20], "rectangle_to_split"
)
assert rect1.sweep_around_axis("Z", sweep_angle=360, draft_angle=0)

def test_45_sweep_along_path(self):
udp1 = [0, 0, 0]
udp2 = [5, 0, 0]
path = self.aedtapp.modeler.primitives.create_polyline([udp1, udp2], name="Poly1")
rect1 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.YZ, [0, 0, 0],
[20, 20], "rectangle_to_sweep")
rect1 = self.aedtapp.modeler.primitives.create_rectangle(
self.aedtapp.PLANE.YZ, [0, 0, 0], [20, 20], "rectangle_to_sweep"
)
assert rect1.sweep_along_path(path)

def test_46_section_object(self):
Expand All @@ -358,8 +350,9 @@ def test_46_section_object(self):

def test_47_sweep_along_vector(self):
sweep_vector = [5, 0, 0]
rect1 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.YZ, [0, 0, 0],
[20, 20], "rectangle_to_vector")
rect1 = self.aedtapp.modeler.primitives.create_rectangle(
self.aedtapp.PLANE.YZ, [0, 0, 0], [20, 20], "rectangle_to_vector"
)
assert rect1.sweep_along_vector(sweep_vector)

def test_48_coordinate_systems_parametric(self):
Expand Down
19 changes: 6 additions & 13 deletions _unittest/test_03_Materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,25 +155,18 @@ def test_09_non_linear_materials(self):
app.materials.export_materials_to_file(os.path.join(self.local_scratch.path, "non_linear.json"))
os.path.exists(os.path.join(self.local_scratch.path, "non_linear.json"))
app.materials.remove_material("myMat")
# Need to edit json file since the dumping doesn't work when embedded in unittest in IPY
with open(os.path.join(self.local_scratch.path, "non_linear.json"), 'r') as file:
filedata = file.read()
filedata = filedata.replace('True', 'true')
filedata = filedata.replace('False', 'false')
with open(os.path.join(self.local_scratch.path, "non_linear2.json"), 'w') as file:
file.write(filedata)
app.materials.import_materials_from_file(os.path.join(self.local_scratch.path, "non_linear2.json"))
app.materials.import_materials_from_file(os.path.join(self.local_scratch.path, "non_linear.json"))
assert app.materials["myMat"].permeability.value == [[0, 0], [1, 12], [10, 30]]
assert app.materials["myMat"].permittivity.value == [[0, 0], [2, 12], [10, 30]]
assert app.materials["myMat"].conductivity.value == [[0, 0], [3, 12], [10, 30]]
assert app.materials["myMat"].permeability.type == 'nonlinear'
assert app.materials["myMat"].conductivity.type == 'nonlinear'
assert app.materials["myMat"].permittivity.type == 'nonlinear'
assert app.materials["myMat"].permeability.bunit == 'tesla'
assert app.materials["myMat"].permeability.type == "nonlinear"
assert app.materials["myMat"].conductivity.type == "nonlinear"
assert app.materials["myMat"].permittivity.type == "nonlinear"
assert app.materials["myMat"].permeability.bunit == "tesla"
mat2 = app.materials.add_material("myMat2")
assert mat2.permeability.set_non_linear([[0, 0], [1, 12], [10, 30]])
assert app.modeler.create_box([0, 0, 0], [10, 10, 10], matname="myMat2")

def test_10_add_material_sweep(self):
assert self.aedtapp.materials.add_material_sweep(["copper3", "new_copper"], "sweep_copper")
assert "sweep_copper" in list(self.aedtapp.materials.material_keys.keys())
assert "sweep_copper" in list(self.aedtapp.materials.material_keys.keys())
8 changes: 2 additions & 6 deletions _unittest/test_05_Mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ def teardown_class(self):
def test_assign_model_resolution(self):
udp = self.aedtapp.modeler.Position(0, 0, 0)
coax_dimension = 200
o = self.aedtapp.modeler.primitives.create_cylinder(
self.aedtapp.PLANE.XY, udp, 3, coax_dimension, 0, "inner"
)
o = self.aedtapp.modeler.primitives.create_cylinder(self.aedtapp.PLANE.XY, udp, 3, coax_dimension, 0, "inner")
self.aedtapp.mesh.assign_model_resolution(o, 1e-4, "ModelRes1")
assert "ModelRes1" in [i.name for i in self.aedtapp.mesh.meshoperations]
mr2 = self.aedtapp.mesh.assign_model_resolution(o.faces[0], 1e-4, "ModelRes2")
Expand All @@ -41,9 +39,7 @@ def test_assign_model_resolution(self):
def test_assign_surface_mesh(self):
udp = self.aedtapp.modeler.Position(10, 10, 0)
coax_dimension = 200
o = self.aedtapp.modeler.primitives.create_cylinder(
self.aedtapp.PLANE.XY, udp, 3, coax_dimension, 0, "surface"
)
o = self.aedtapp.modeler.primitives.create_cylinder(self.aedtapp.PLANE.XY, udp, 3, coax_dimension, 0, "surface")
surface = self.aedtapp.mesh.assign_surface_mesh(o.id, 3, "Surface")
assert "Surface" in [i.name for i in self.aedtapp.mesh.meshoperations]
assert surface.props["SliderMeshSettings"] == 3
Expand Down
8 changes: 7 additions & 1 deletion _unittest/test_07_Object3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setup_class(self):
test_projectfile = os.path.join(self.local_scratch.path, "test_object3d" + ".aedt")
self.aedtapp = Hfss()
self.aedtapp.save_project(project_file=test_projectfile)
#self.prim = self.aedtapp.modeler
# self.prim = self.aedtapp.modeler

def teardown_class(self):
self.aedtapp._desktop.ClearMessages("", "", 3)
Expand Down Expand Up @@ -337,3 +337,9 @@ def test_16_duplicate_around_axis_and_unite(self):
def test_17_section_object(self):
o = self.aedtapp.modeler.primitives.create_box([-10, 0, 0], [10, 10, 5], "SectionBox", "Copper")
o.section(plane="YZ", create_new=True, section_cross_object=False)

def test_18_create_spiral(self):
sp1 = self.aedtapp.modeler.create_spiral(name="ind")
assert sp1
assert sp1.name == "ind"
assert len(sp1.points) == 78
2 changes: 1 addition & 1 deletion _unittest/test_09_VariableManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def test_12_decompose_variable_value(self):
assert decompose_variable_value("3.123456m") == (3.123456, "m")
assert decompose_variable_value("3m") == (3, "m")
assert decompose_variable_value("3") == (3, "")
assert decompose_variable_value("3.") == (3., "")
assert decompose_variable_value("3.") == (3.0, "")
assert decompose_variable_value("3.123456m2") == (3.123456, "m2")
assert decompose_variable_value("3.123456Nm-2") == (3.123456, "Nm-2")
assert decompose_variable_value("3.123456kg2m2") == (3.123456, "kg2m2")
Expand Down
Loading

0 comments on commit f1df886

Please sign in to comment.