Skip to content

Removed modeler.primitives from unit tests and examples as it is deprecated. #837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _unittest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def inner_function(*args, **kwargs):
except Exception as e:
pytest.exit("Desktop Crashed - Aborting the test!")
args[0].cache.update()
# model_report = args[0].aedtapp.modeler.primitives.model_consistency_report
# model_report = args[0].aedtapp.modeler.model_consistency_report
# assert not model_report["Missing Objects"]
# assert not model_report["Non-Existent Objects"]
assert args[0].cache.no_new_errors
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_01_Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_09_set_objects_deformation(self):

def test_09_set_objects_temperature(self):
ambient_temp = 22
objects = [o for o in self.aedtapp.modeler.primitives.solid_names if self.aedtapp.modeler.primitives[o].model]
objects = [o for o in self.aedtapp.modeler.solid_names if self.aedtapp.modeler[o].model]
assert self.aedtapp.modeler.set_objects_temperature(objects, ambient_temp=ambient_temp, create_project_var=True)

def test_10_change_material_override(self):
Expand Down
26 changes: 13 additions & 13 deletions _unittest/test_02_2D_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def test_03_objects(self):
assert self.aedtapp.modeler._omaterial_manager

def test_create_rectangle(self):
rect1 = self.aedtapp.modeler.primitives.create_rectangle([0, -2, -2], [3, 8])
rect2 = self.aedtapp.modeler.primitives.create_rectangle(
rect1 = self.aedtapp.modeler.create_rectangle([0, -2, -2], [3, 8])
rect2 = self.aedtapp.modeler.create_rectangle(
position=[10, -2, -2], dimension_list=[3, 10], name="MyRectangle", matname="Copper"
)
assert rect1.solve_inside
Expand All @@ -67,8 +67,8 @@ def test_create_rectangle(self):

def test_create_rectangle_rz(self):
self.aedtapp.solution_type = "MagnetostaticZ"
rect1 = self.aedtapp.modeler.primitives.create_rectangle([1, 0, -2], [8, 3])
rect2 = self.aedtapp.modeler.primitives.create_rectangle(
rect1 = self.aedtapp.modeler.create_rectangle([1, 0, -2], [8, 3])
rect2 = self.aedtapp.modeler.create_rectangle(
position=[10, 0, -2], dimension_list=[10, 3], name="MyRectangle", matname="Copper"
)
list_of_pos = [ver.position for ver in rect1.vertices]
Expand All @@ -78,8 +78,8 @@ def test_create_rectangle_rz(self):
assert sorted(list_of_pos) == [[10.0, 0.0, -2.0], [10.0, 0.0, 8.0], [13.0, 0.0, -2.0], [13.0, 0.0, 8.0]]

def test_create_circle(self):
circle1 = self.aedtapp.modeler.primitives.create_circle([0, -2, 0], 3)
circle2 = self.aedtapp.modeler.primitives.create_circle(
circle1 = self.aedtapp.modeler.create_circle([0, -2, 0], 3)
circle2 = self.aedtapp.modeler.create_circle(
position=[0, -2, -2], radius=3, num_sides=6, name="MyCircle", matname="Copper"
)
assert circle1.solve_inside
Expand All @@ -93,8 +93,8 @@ def test_create_circle(self):
assert isclose(circle1.faces[0].area, math.pi * 3.0 * 3.0)

def test_create_ellipse(self):
ellipse1 = self.aedtapp.modeler.primitives.create_ellipse([0, -2, 0], 4.0, 0.2)
ellipse2 = self.aedtapp.modeler.primitives.create_ellipse(
ellipse1 = self.aedtapp.modeler.create_ellipse([0, -2, 0], 4.0, 0.2)
ellipse2 = self.aedtapp.modeler.create_ellipse(
position=[0, -2, 0], major_radius=4.0, ratio=0.2, name="MyEllipse", matname="Copper"
)
assert ellipse1.solve_inside
Expand All @@ -108,8 +108,8 @@ def test_create_ellipse(self):
assert isclose(ellipse2.faces[0].area, math.pi * 4.0 * 4.0 * 0.2)

def test_create_regular_polygon(self):
pg1 = self.aedtapp.modeler.primitives.create_regular_polygon([0, 0, 0], [0, 2, 0])
pg2 = self.aedtapp.modeler.primitives.create_regular_polygon(
pg1 = self.aedtapp.modeler.create_regular_polygon([0, 0, 0], [0, 2, 0])
pg2 = self.aedtapp.modeler.create_regular_polygon(
position=[0, 0, 0], start_point=[0, 2, 0], num_sides=3, name="MyPolygon", matname="Copper"
)
assert pg1.solve_inside
Expand All @@ -124,14 +124,14 @@ def test_create_regular_polygon(self):

@pytest.mark.skipif(config["build_machine"] or is_ironpython, reason="Not running in ironpython")
def test_plot(self):
self.aedtapp.modeler.primitives.create_regular_polygon([0, 0, 0], [0, 2, 0])
self.aedtapp.modeler.primitives.create_regular_polygon(
self.aedtapp.modeler.create_regular_polygon([0, 0, 0], [0, 2, 0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some lines, like this one, without an assert. Any reason why there is no assert?
They are notified by codecov.
Maybe we can exclude all unit tests from code coverage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because those one are needed to the test assertion which is a couple of lines below

self.aedtapp.modeler.create_regular_polygon(
position=[0, 0, 0], start_point=[0, 2, 0], num_sides=3, name="MyPolygon", matname="Copper"
)
obj = self.aedtapp.plot(show=False, export_path=os.path.join(self.local_scratch.path, "image.jpg"))
assert os.path.exists(obj.image_file)

def test_edit_menu_commands(self):
rect1 = self.aedtapp.modeler.primitives.create_rectangle([1, 0, -2], [8, 3])
rect1 = self.aedtapp.modeler.create_rectangle([1, 0, -2], [8, 3])
assert self.aedtapp.modeler.mirror(rect1, [1, 0, 0], [1, 0, 0])
assert self.aedtapp.modeler.move(rect1, [1, 1, 0])
68 changes: 31 additions & 37 deletions _unittest/test_02_3D_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ def setup_class(self):

def restore_model(self):
for name in self.aedtapp.modeler.get_matched_object_name("outer*"):
self.aedtapp.modeler.primitives.delete(name)
outer = self.aedtapp.modeler.primitives.create_cylinder(
self.aedtapp.modeler.delete(name)
outer = self.aedtapp.modeler.create_cylinder(
cs_axis="X", position=[0, 0, 0], radius=1, height=20, name="outer", matname="Aluminum"
)
for name in self.aedtapp.modeler.get_matched_object_name("Core*"):
self.aedtapp.modeler.primitives.delete(name)
core = self.aedtapp.modeler.primitives.create_cylinder(
self.aedtapp.modeler.delete(name)
core = self.aedtapp.modeler.create_cylinder(
cs_axis="X", position=[0, 0, 0], radius=0.8, height=20, name="Core", matname="teflon_based"
)
for name in self.aedtapp.modeler.get_matched_object_name("inner*"):
self.aedtapp.modeler.primitives.delete(name)
inner = self.aedtapp.modeler.primitives.create_cylinder(
self.aedtapp.modeler.delete(name)
inner = self.aedtapp.modeler.create_cylinder(
cs_axis="X", position=[0, 0, 0], radius=0.3, height=20, name="inner", matname="Aluminum"
)

for name in self.aedtapp.modeler.get_matched_object_name("Poly1*"):
self.aedtapp.modeler.primitives.delete(name)
self.aedtapp.modeler.delete(name)
udp1 = [0, 0, 0]
udp2 = [5, 0, 0]
udp3 = [5, 5, 0]
self.aedtapp.modeler.primitives.create_polyline([udp1, udp2, udp3], name="Poly1", xsection_type="Rectangle")
self.aedtapp.modeler.create_polyline([udp1, udp2, udp3], name="Poly1", xsection_type="Rectangle")

self.aedtapp.modeler.subtract(outer, core)
self.aedtapp.modeler.subtract(core, inner)
Expand Down Expand Up @@ -62,7 +62,7 @@ def test_04_convert_to_selection(self):

@pyaedt_unittest_check_desktop_error
def test_05_split(self):
box1 = self.aedtapp.modeler.primitives.create_box([-10, -10, -10], [20, 20, 20], "box_to_split")
box1 = self.aedtapp.modeler.create_box([-10, -10, -10], [20, 20, 20], "box_to_split")
assert self.aedtapp.modeler.split("box_to_split", 2)

@pyaedt_unittest_check_desktop_error
Expand Down Expand Up @@ -102,9 +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.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.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 All @@ -125,21 +125,21 @@ def test_13_rotate(self):
assert self.aedtapp.modeler.rotate("Poly1", self.aedtapp.AXIS.X, 30)

def test_14_subtract(self):
o1 = self.aedtapp.modeler.primitives["outer"].clone()
o2 = self.aedtapp.modeler.primitives["inner"].clone()
o1 = self.aedtapp.modeler["outer"].clone()
o2 = self.aedtapp.modeler["inner"].clone()
assert self.aedtapp.modeler.subtract(o1, o2)

def test_15_purge_history(self):
o1 = self.aedtapp.modeler.primitives["outer"].clone()
o2 = self.aedtapp.modeler.primitives["inner"].clone()
o1 = self.aedtapp.modeler["outer"].clone()
o2 = self.aedtapp.modeler["inner"].clone()
assert self.aedtapp.modeler.purge_history([o1, o2])

def test_16_get_model_bounding_box(self):
assert len(self.aedtapp.modeler.get_model_bounding_box()) == 6

def test_17_unite(self):
o1 = self.aedtapp.modeler.primitives["outer"].clone()
o2 = self.aedtapp.modeler.primitives["inner"].clone()
o1 = self.aedtapp.modeler["outer"].clone()
o2 = self.aedtapp.modeler["inner"].clone()
assert self.aedtapp.modeler.unite([o1, o2])

def test_18_chamfer(self):
Expand All @@ -153,21 +153,21 @@ 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.create_rectangle(self.aedtapp.PLANE.XY, udp, [5, 10], name="Rect1")
o2 = self.aedtapp.modeler.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])
id1 = self.aedtapp.modeler.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.create_rectangle(self.aedtapp.PLANE.XY, udp, [-3, 10])
assert self.aedtapp.modeler.connect([id1, id2])

def test_22_translate(self):
udp = [0, 0, 0]
id1 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.XY, udp, [5, 10])
id2 = self.aedtapp.modeler.primitives.create_rectangle(self.aedtapp.PLANE.XY, udp, [3, 12])
id1 = self.aedtapp.modeler.create_rectangle(self.aedtapp.PLANE.XY, udp, [5, 10])
id2 = self.aedtapp.modeler.create_rectangle(self.aedtapp.PLANE.XY, udp, [3, 12])
udp2 = self.aedtapp.modeler.Position(0, 20, 5)
assert self.aedtapp.modeler.translate([id1, id2], udp2)

Expand All @@ -178,7 +178,7 @@ def test_23_chassis_subtraction(self):
def test_24_check_plane(self):

udp = [0, 0, 0]
o1 = self.aedtapp.modeler.primitives.create_box(udp, [4, 5, 5])
o1 = self.aedtapp.modeler.create_box(udp, [4, 5, 5])
plane = self.aedtapp.modeler.check_plane(o1.id, udp)
planes = ["XY", "XZ", "YZ"]
assert plane in planes
Expand All @@ -198,7 +198,7 @@ def test_27_create_region(self):
assert self.aedtapp.modeler.edit_region_dimensions([40, 30, 30, 50, 50, 100])

def test_28_create_face_list(self):
fl = self.aedtapp.modeler.primitives.get_object_faces("Second_airbox")
fl = self.aedtapp.modeler.get_object_faces("Second_airbox")
assert self.aedtapp.modeler.create_face_list(fl, "my_face_list")

def test_28B_create_object_list(self):
Expand Down Expand Up @@ -233,7 +233,7 @@ def test_31_set_objects_unmodel(self):
assert self.aedtapp.modeler.set_object_model_state("Second_airbox", False)

def test_33_duplicate_around_axis(self):
id1 = self.aedtapp.modeler.primitives.create_box([10, 10, 10], [4, 5, 5])
id1 = self.aedtapp.modeler.create_box([10, 10, 10], [4, 5, 5])
axis = self.aedtapp.AXIS.X
_, obj_list = self.aedtapp.modeler.duplicate_around_axis(
id1, cs_axis=axis, angle="180deg", nclones=2, create_new_objects=False
Expand Down Expand Up @@ -329,30 +329,24 @@ 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.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"
)
path = self.aedtapp.modeler.create_polyline([udp1, udp2], name="Poly1")
rect1 = self.aedtapp.modeler.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):
box1 = self.aedtapp.modeler.primitives.create_box([-10, -10, -10], [20, 20, 20], "box_to_split")
box1 = self.aedtapp.modeler.create_box([-10, -10, -10], [20, 20, 20], "box_to_split")
assert self.aedtapp.modeler.section(box1, 0, create_new=True, section_cross_object=False)
pass

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.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
10 changes: 4 additions & 6 deletions _unittest/test_05_Mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +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.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 @@ -39,17 +39,15 @@ 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.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

def test_assign_surface_mesh_manual(self):
udp = self.aedtapp.modeler.Position(20, 20, 0)
coax_dimension = 200
o = self.aedtapp.modeler.primitives.create_cylinder(
self.aedtapp.PLANE.XY, udp, 3, coax_dimension, 0, "surface_manual"
)
o = self.aedtapp.modeler.create_cylinder(self.aedtapp.PLANE.XY, udp, 3, coax_dimension, 0, "surface_manual")
surface = self.aedtapp.mesh.assign_surface_mesh_manual(o.id, 1e-6, aspect_ratio=3, meshop_name="Surface_Manual")
assert "Surface_Manual" in [i.name for i in self.aedtapp.mesh.meshoperations]
assert surface.props["SurfDev"] == 1e-6
Expand All @@ -69,7 +67,7 @@ def test_curvature_extraction(self):

def test_maxwell_mesh(self):
m3d = Maxwell3d()
o = m3d.modeler.primitives.create_box([0, 0, 0], [10, 10, 10], name="Box_Mesh")
o = m3d.modeler.create_box([0, 0, 0], [10, 10, 10], name="Box_Mesh")
assert m3d.mesh.assign_rotational_layer(o.name, meshop_name="Rotational")
assert m3d.mesh.assign_edge_cut(o.name, meshop_name="Edge")
assert m3d.mesh.assign_density_control(o.name, maxelementlength=10000, meshop_name="Density")
Loading