Skip to content

Commit 6fe19ab

Browse files
authored
Allow stackup thickness and area weight to be None (#873)
When the fabrics in a stackup do have a material, or the stackup has no fabrics, the 'thickness' and 'area_weight' properties cannot be computed. This change allows these properties to be 'None' in these cases. This case is only supported in the 26.1 server version or later. Earlier versions would raise an error when getting the properties under these conditions.
1 parent 9fc6f14 commit 6fe19ab

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ numpy = ">=1.22"
3939
grpcio-health-checking = ">=1.43"
4040
packaging = ">=15.0"
4141
typing-extensions = ">=4.5.0"
42-
ansys-api-acp = "==0.3.0"
42+
ansys-api-acp = "==0.3.1"
4343
ansys-tools-path = ">=0"
4444
ansys-tools-local-product-launcher = ">=0.1"
4545
ansys-tools-filetransfer = ">=0.1"

src/ansys/acp/core/_tree_objects/stackup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,12 @@ def _create_stub(self) -> stackup_pb2_grpc.ObjectServiceStub:
222222

223223
locked: ReadOnlyProperty[bool] = grpc_data_property_read_only("properties.locked")
224224
status = grpc_data_property_read_only("properties.status", from_protobuf=status_type_from_pb)
225-
thickness: ReadOnlyProperty[float] = grpc_data_property_read_only("properties.thickness")
226-
area_weight: ReadOnlyProperty[float] = grpc_data_property_read_only("properties.area_weight")
225+
thickness: ReadOnlyProperty[float] = grpc_data_property_read_only(
226+
"properties.thickness", check_optional=True
227+
)
228+
area_weight: ReadOnlyProperty[float] = grpc_data_property_read_only(
229+
"properties.area_weight", check_optional=True
230+
)
227231

228232
symmetry = grpc_data_property(
229233
"properties.symmetry",

tests/unittests/test_stackup.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,22 @@ def test_add_fabric(parent_object):
190190
assert stackup.fabrics[-1].angle == 45.0
191191

192192

193-
def test_fabric_wit_angle(parent_object):
193+
def test_fabric_with_angle(parent_object):
194194
fabric1 = parent_object.create_fabric()
195195
fabric_with_angle = FabricWithAngle(fabric=fabric1, angle=45.0)
196196
assert fabric_with_angle != FabricWithAngle(fabric=parent_object.create_fabric(), angle=45.0)
197197
assert fabric_with_angle != FabricWithAngle(fabric=fabric1, angle=55.0)
198198
assert fabric_with_angle == FabricWithAngle(fabric=fabric1, angle=45.0)
199+
200+
201+
def test_fabric_without_material(parent_object, skip_before_version):
202+
"""Verify that a fabric without material can be added to a stackup.
203+
204+
Checks that the properties which should not be computable are 'None'.
205+
"""
206+
skip_before_version("26.1")
207+
fabric = parent_object.create_fabric()
208+
stackup = parent_object.create_stackup()
209+
stackup.add_fabric(fabric)
210+
assert stackup.thickness is None
211+
assert stackup.area_weight is None

0 commit comments

Comments
 (0)