Skip to content
Draft
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
244 changes: 81 additions & 163 deletions src/moldflow/boundary_conditions.py

Large diffs are not rendered by default.

24 changes: 8 additions & 16 deletions src/moldflow/cad_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .ent_list import EntList
from .vector import Vector
from .logger import process_log, LogMessage
from .helper import check_type, coerce_optional_dispatch
from .helper import check_type, check_and_coerce_optional
from .com_proxy import safe_com


Expand Down Expand Up @@ -60,14 +60,11 @@ def modify_cad_surfaces_by_normal(
process_log(
__name__, LogMessage.FUNCTION_CALL, locals(), name="modify_cad_surfaces_by_normal"
)
if faces is not None:
check_type(faces, EntList)
if transit_faces is not None:
check_type(transit_faces, EntList)

check_type(distance, (float, int))
return self.cad_manager.ModifyCADSurfacesByNormal(
coerce_optional_dispatch(faces, "ent_list"),
coerce_optional_dispatch(transit_faces, "ent_list"),
check_and_coerce_optional(faces, EntList),
check_and_coerce_optional(transit_faces, EntList),
distance,
)

Expand All @@ -89,14 +86,9 @@ def modify_cad_surfaces_by_vector(
process_log(
__name__, LogMessage.FUNCTION_CALL, locals(), name="modify_cad_surfaces_by_vector"
)
if faces is not None:
check_type(faces, EntList)
if transit_faces is not None:
check_type(transit_faces, EntList)
if vector is not None:
check_type(vector, Vector)

return self.cad_manager.ModifyCADSurfacesByVector(
coerce_optional_dispatch(faces, "ent_list"),
coerce_optional_dispatch(transit_faces, "ent_list"),
coerce_optional_dispatch(vector, "vector"),
check_and_coerce_optional(faces, EntList),
check_and_coerce_optional(transit_faces, EntList),
check_and_coerce_optional(vector, Vector),
)
1 change: 0 additions & 1 deletion src/moldflow/com_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from .common import LogMessage
from .errors import raise_attribute_error


# ------------------------------------------------------------------
# Helper: Verify COM attribute existence
# ------------------------------------------------------------------
Expand Down
63 changes: 20 additions & 43 deletions src/moldflow/data_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

from .logger import process_log, LogMessage
from .helper import check_type, get_enum_value, coerce_optional_dispatch
from .helper import check_type, check_and_coerce_optional, get_enum_value
from .com_proxy import safe_com
from .common import TransformFunctions, TransformOperations, TransformScalarOperations
from .integer_array import IntegerArray
Expand Down Expand Up @@ -53,20 +53,13 @@ def func(
"""
process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="func")
func_name = get_enum_value(func_name, TransformFunctions)
if label_in is not None:
check_type(label_in, IntegerArray)
if data_in is not None:
check_type(data_in, DoubleArray)
if label_out is not None:
check_type(label_out, IntegerArray)
if data_out is not None:
check_type(data_out, DoubleArray)

return self.data_transform.Func(
func_name,
coerce_optional_dispatch(label_in, "integer_array"),
coerce_optional_dispatch(data_in, "double_array"),
coerce_optional_dispatch(label_out, "integer_array"),
coerce_optional_dispatch(data_out, "double_array"),
check_and_coerce_optional(label_in, IntegerArray),
check_and_coerce_optional(data_in, DoubleArray),
check_and_coerce_optional(label_out, IntegerArray),
check_and_coerce_optional(data_out, DoubleArray),
)

# pylint: disable=R0913, R0917
Expand Down Expand Up @@ -96,27 +89,17 @@ def op(
bool: True if the operation was applied successfully, False otherwise.
"""
process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="op")
if label_1 is not None:
check_type(label_1, IntegerArray)
if data_1 is not None:
check_type(data_1, DoubleArray)

op = get_enum_value(op, TransformOperations)
if label_2 is not None:
check_type(label_2, IntegerArray)
if data_2 is not None:
check_type(data_2, DoubleArray)
if label_out is not None:
check_type(label_out, IntegerArray)
if data_out is not None:
check_type(data_out, DoubleArray)

return self.data_transform.Op(
coerce_optional_dispatch(label_1, "integer_array"),
coerce_optional_dispatch(data_1, "double_array"),
check_and_coerce_optional(label_1, IntegerArray),
check_and_coerce_optional(data_1, DoubleArray),
op,
coerce_optional_dispatch(label_2, "integer_array"),
coerce_optional_dispatch(data_2, "double_array"),
coerce_optional_dispatch(label_out, "integer_array"),
coerce_optional_dispatch(data_out, "double_array"),
check_and_coerce_optional(label_2, IntegerArray),
check_and_coerce_optional(data_2, DoubleArray),
check_and_coerce_optional(label_out, IntegerArray),
check_and_coerce_optional(data_out, DoubleArray),
)

# pylint: disable=R0913, R0917
Expand Down Expand Up @@ -144,21 +127,15 @@ def scalar(
bool: True if the scalar operation was applied successfully, False otherwise.
"""
process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="scalar")
if label_in is not None:
check_type(label_in, IntegerArray)
if data_in is not None:
check_type(data_in, DoubleArray)

op = get_enum_value(op, TransformScalarOperations)
check_type(scalar_value, (float, int))
if label_out is not None:
check_type(label_out, IntegerArray)
if data_out is not None:
check_type(data_out, DoubleArray)

return self.data_transform.Scalar(
coerce_optional_dispatch(label_in, "integer_array"),
coerce_optional_dispatch(data_in, "double_array"),
check_and_coerce_optional(label_in, IntegerArray),
check_and_coerce_optional(data_in, DoubleArray),
op,
scalar_value,
coerce_optional_dispatch(label_out, "integer_array"),
coerce_optional_dispatch(data_out, "double_array"),
check_and_coerce_optional(label_out, IntegerArray),
check_and_coerce_optional(data_out, DoubleArray),
)
Loading
Loading