Skip to content

Commit 9606e37

Browse files
committed
Merge branch 'docs/min-version-docstring' of https://github.com/ansys/pyansys-geometry into docs/min-version-docstring
2 parents 13cd9e3 + 9c07609 commit 9606e37

File tree

7 files changed

+127
-5
lines changed

7 files changed

+127
-5
lines changed

doc/changelog.d/2060.documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add proper disclaimer to binaries repository

doc/changelog.d/2061.test.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Expanding test coverage for designer and math

doc/changelog.d/2062.documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add notes section for minimum version on methods

doc/source/assets.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ Windows container
6666

6767
.. note::
6868

69-
Only users with access to https://github.com/ansys/pyansys-geometry-binaries can download these binaries.
69+
Only Ansys employees with access to
70+
https://github.com/ansys/pyansys-geometry-binaries can download these binaries.
7071

7172
* `Latest Geometry service binaries for Windows containers <https://github.com/ansys/pyansys-geometry-binaries>`_
7273
* `Latest Geometry service Dockerfile for Windows containers <https://github.com/ansys/pyansys-geometry/releases/latest/download/windows-core-dockerfile.zip>`_

doc/source/getting_started/docker/windows_container.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ There are two build modes:
115115
the binaries available in the `ansys/pyansys-geometry-binaries <https://github.com/ansys/pyansys-geometry-binaries>`_ repository.
116116
If you do not have access to this repository, you can only use the first mode.
117117

118+
.. note::
119+
120+
Only Ansys employees with access to
121+
https://github.com/ansys/pyansys-geometry-binaries can download these binaries.
122+
118123
Prerequisites
119124
~~~~~~~~~~~~~
120125

@@ -162,7 +167,8 @@ Prior to building your image, follow these steps:
162167

163168
.. note::
164169

165-
Only users with access to https://github.com/ansys/pyansys-geometry-binaries can download these binaries.
170+
Only Ansys employees with access to
171+
https://github.com/ansys/pyansys-geometry-binaries can download these binaries.
166172

167173
* Move this ZIP file to the location of the Windows Dockerfile previously downloaded.
168174

tests/integration/test_design.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
SharedTopologyType,
3838
SurfaceType,
3939
)
40-
from ansys.geometry.core.designer.body import CollisionType, FillStyle
40+
from ansys.geometry.core.designer.body import CollisionType, FillStyle, MasterBody
4141
from ansys.geometry.core.designer.face import FaceLoopType
42+
from ansys.geometry.core.designer.part import MasterComponent, Part
4243
from ansys.geometry.core.errors import GeometryExitedError
4344
from ansys.geometry.core.materials import Material, MaterialProperty, MaterialPropertyType
4445
from ansys.geometry.core.math import (
@@ -76,6 +77,38 @@
7677
from .conftest import FILES_DIR
7778

7879

80+
def test_design_selection(modeler: Modeler):
81+
"""Test to validate the designer selection for edges and __repr__ method."""
82+
sketch = Sketch()
83+
sketch.box(Point2D([0, 0]), 10, 10)
84+
design = modeler.create_design("Box")
85+
body = design.extrude_sketch("Box", sketch, Quantity(2, UNITS.m))
86+
ns_edge = design.create_named_selection("The Edges", body.edges[0:2])
87+
assert ns_edge.edges[0].start == Point3D([-5, -5, 2])
88+
assert ns_edge.edges[0].end == Point3D([5, -5, 2])
89+
assert ns_edge.edges[1].start == Point3D([-5, -5, 0])
90+
assert ns_edge.edges[1].end == Point3D([-5, -5, 2])
91+
assert ns_edge.__repr__()[0:54] == "ansys.geometry.core.designer.selection.NamedSelection "
92+
93+
94+
def test_design_part(modeler: Modeler):
95+
"""Test to validate the designer part id, name, and setter for components and bodies."""
96+
body1 = MasterBody(id="body1", name="First Only Body", grpc_client=modeler.client)
97+
body2 = MasterBody(id="body2", name="Second Body in Component", grpc_client=modeler.client)
98+
bodies = [body1]
99+
part = Part(id="IDPart", name="NamePart", components=[], bodies=bodies)
100+
masterpart = MasterComponent(id="PartMaster", name="Part Master", part=part)
101+
assert masterpart.id == "PartMaster"
102+
assert masterpart.name == "Part Master"
103+
assert masterpart.__repr__()[0:50] == "MasterComponent(id=PartMaster, name=Part Master, t"
104+
assert part.id == "IDPart"
105+
assert part.name == "NamePart"
106+
part.components = [body2]
107+
assert part.components[0].name == "Second Body in Component"
108+
part.bodies = body1
109+
assert part.bodies.name == "First Only Body"
110+
111+
79112
def test_design_extrusion_and_material_assignment(modeler: Modeler):
80113
"""Test to validate the extrusion of a simple circle as a cylinder and the
81114
assignment of materials to it.

tests/test_math.py

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,39 @@
5050
Vector3D,
5151
get_two_circle_intersections,
5252
)
53+
from ansys.geometry.core.math.misc import intersect_interval
5354
from ansys.geometry.core.misc import UNITS
5455

5556
DOUBLE_EPS = np.finfo(float).eps
5657

5758

59+
def test_intersect_interval():
60+
first_interval_min = 10
61+
first_interval_max = 1
62+
second_interval_min = 5
63+
second_interval_max = 2
64+
65+
intersect, intersection_min, intersection_max = intersect_interval(
66+
first_interval_min, second_interval_min, first_interval_max, second_interval_max
67+
)
68+
assert intersect is False
69+
assert intersection_min == 0
70+
assert intersection_max == 0
71+
72+
# 132
73+
first_interval_min = 10
74+
first_interval_max = 15
75+
second_interval_min = 5
76+
second_interval_max = 20
77+
78+
intersect, intersection_min, intersection_max = intersect_interval(
79+
first_interval_min, second_interval_min, first_interval_max, second_interval_max
80+
)
81+
assert intersect is True
82+
assert intersection_min == 10
83+
assert intersection_max == 15
84+
85+
5886
def test_point():
5987
"""Simple test to create ``Point2D`` and ``Point3D``."""
6088
# Test the default Point3D
@@ -392,6 +420,11 @@ def test_vector3d():
392420
assert UNITVECTOR3D_X.is_opposite(Vector3D([-1, 0, 0]))
393421
assert not UNITVECTOR3D_X.is_opposite(UNITVECTOR3D_X)
394422

423+
# Testing it fails for zero 2D vectors
424+
vector1 = Vector3D([0, 0, 0])
425+
vector2 = Vector3D([0, 0, 0])
426+
assert vector1.is_parallel_to(vector2) is False
427+
395428

396429
def test_vector2d():
397430
"""Simple test to create ``Vector2D``."""
@@ -478,6 +511,11 @@ def test_vector2d():
478511
assert UNITVECTOR2D_X.is_opposite(Vector2D([-1, 0]))
479512
assert not UNITVECTOR2D_X.is_opposite(UNITVECTOR2D_X)
480513

514+
# Testing it fails for zero 2D vectors
515+
vector1 = Vector2D([0, 0])
516+
vector2 = Vector2D([0, 0])
517+
assert vector1.is_parallel_to(vector2) is False
518+
481519

482520
def test_unitvector3d():
483521
"""Simple test to create a ``UnitVector3D``."""
@@ -646,6 +684,12 @@ def test_rotate_vector():
646684
# Assert that the result matches the expected vector
647685
assert np.allclose(result_vector, expected_vector)
648686

687+
# Testing that the vector cannot be zero
688+
vector1 = Vector3D([0, 0, 0])
689+
vector2 = Vector3D([0, 0, 0])
690+
with pytest.raises(Exception, match="Invalid vector operation: rotation axis cannot be zero."):
691+
vector1.rotate_vector(vector2, np.pi)
692+
649693

650694
def test_matrix():
651695
"""Simple test to create a ``Matrix``."""
@@ -679,6 +723,18 @@ def test_matrix():
679723
with pytest.raises(ValueError, match="Matrix should only be a 2D array."):
680724
Matrix([None, None, None, None, None])
681725

726+
# 221 checking if the 2nd row is part of identify matrix
727+
matrix = Matrix44([[1, 0, 0, 5], [1, 1, 0, 3], [0, 0, 1, 2], [0, 0, 0, 1]])
728+
assert matrix.is_translation() is False
729+
730+
# 227 checking if the 3rd row is part of identify matrix
731+
matrix = Matrix44([[1, 0, 0, 5], [0, 1, 0, 3], [0, 0, 0.5, 2], [0, 0, 0, 1]])
732+
assert matrix.is_translation() is False
733+
734+
# 229 - not sure if this needed since it should be covered in 227
735+
matrix = Matrix44([[1, 0, 0, 5], [0, 1, 0, 3], [0, 0, 0.8, 2], [0, 0, 0, 1]])
736+
assert matrix.is_translation() is False
737+
682738

683739
def test_matrix_errors():
684740
"""Testing multiple ``Matrix`` errors."""
@@ -706,6 +762,15 @@ def test_matrix_errors():
706762
):
707763
m_1 * m_2
708764

765+
# Error if x and y vectors are not orthongonal for rotation
766+
matrix = Matrix44([[1, 0, 0, 5], [1, 0, 0, 3], [0, 0, 1, 2], [0, 0, 0, 1]])
767+
with pytest.raises(ValueError, match="The provided direction vectors are not orthogonal."):
768+
matrix.create_rotation(Vector3D([1, 0, 0]), Vector3D([1, 0, 0]))
769+
770+
# Error if x and z and y and z are not orthongonal for rotation
771+
with pytest.raises(ValueError, match="The provided direction vectors are not orthogonal."):
772+
matrix.create_rotation(Vector3D([1, 0, 0]), Vector3D([0, 1, 0]), Vector3D([1, 1, 0]))
773+
709774

710775
def test_matrix_33():
711776
"""Simple test to create a ``Matrix33``."""
@@ -1335,9 +1400,13 @@ def test_bounding_box2d_no_intersection():
13351400
box1 = BoundingBox2D(0, 1, 0, 1)
13361401
box2 = BoundingBox2D(2, 3, 0, 1)
13371402

1338-
# Get intersection and check
1403+
# Get intersection for x and check
13391404
intersection = BoundingBox2D.intersect_bboxes(box1, box2)
13401405
assert intersection is None
1406+
# Get intersection for y and check
1407+
boxfirst = BoundingBox2D(0, 5, 0, 5)
1408+
boxsecond = BoundingBox2D(3, 8, 6, 8)
1409+
assert BoundingBox2D.intersect_bboxes(boxfirst, boxsecond) is None
13411410

13421411

13431412
def test_bounding_box_evaluates_bounds_comparisons():
@@ -1373,6 +1442,16 @@ def test_bounding_box_no_intersection():
13731442
box1 = BoundingBox(Point3D([0, 0, 0]), Point3D([1, 1, 0]))
13741443
box2 = BoundingBox(Point3D([2, 0, 0]), Point3D([3, 1, 0]))
13751444

1376-
# Get intersection and check
1445+
# Get intersection for x and check
13771446
intersection = BoundingBox.intersect_bboxes(box1, box2)
13781447
assert intersection is None
1448+
1449+
# Get intersection for y and check
1450+
firstboxbounding = BoundingBox(Point3D([-1, -1, -1]), Point3D([2, 1, 1]), Point3D([0, 0, 0]))
1451+
secondboxbounding = BoundingBox(Point3D([2, 2, 2]), Point3D([3, 3, 3]), Point3D([4, 4, 4]))
1452+
assert BoundingBox.intersect_bboxes(firstboxbounding, secondboxbounding) is None
1453+
1454+
# Get intersection for z and check
1455+
firstboxbounding = BoundingBox(Point3D([-1, -1, -1]), Point3D([2, 2, 1]), Point3D([0, 0, 0]))
1456+
secondboxbounding = BoundingBox(Point3D([2, 2, 2]), Point3D([3, 3, 3]), Point3D([4, 4, 4]))
1457+
assert BoundingBox.intersect_bboxes(firstboxbounding, secondboxbounding) is None

0 commit comments

Comments
 (0)