|
7 | 7 | """ |
8 | 8 |
|
9 | 9 | from .logger import process_log, LogMessage |
10 | | -from .helper import check_type, check_optional_type, get_enum_value, coerce_optional_dispatch |
| 10 | +from .helper import check_type, check_optional_type, check_and_coerce_optional, get_enum_value, coerce_optional_dispatch |
11 | 11 | from .com_proxy import safe_com |
12 | 12 | from .common import TransformFunctions, TransformOperations, TransformScalarOperations |
13 | 13 | from .integer_array import IntegerArray |
@@ -53,16 +53,13 @@ def func( |
53 | 53 | """ |
54 | 54 | process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="func") |
55 | 55 | func_name = get_enum_value(func_name, TransformFunctions) |
56 | | - check_optional_type(label_in, IntegerArray) |
57 | | - check_optional_type(data_in, DoubleArray) |
58 | | - check_optional_type(label_out, IntegerArray) |
59 | | - check_optional_type(data_out, DoubleArray) |
| 56 | + |
60 | 57 | return self.data_transform.Func( |
61 | 58 | func_name, |
62 | | - coerce_optional_dispatch(label_in, "integer_array"), |
63 | | - coerce_optional_dispatch(data_in, "double_array"), |
64 | | - coerce_optional_dispatch(label_out, "integer_array"), |
65 | | - coerce_optional_dispatch(data_out, "double_array"), |
| 59 | + check_and_coerce_optional(label_in, IntegerArray), |
| 60 | + check_and_coerce_optional(data_in, DoubleArray), |
| 61 | + check_and_coerce_optional(label_out, IntegerArray), |
| 62 | + check_and_coerce_optional(data_out, DoubleArray), |
66 | 63 | ) |
67 | 64 |
|
68 | 65 | # pylint: disable=R0913, R0917 |
@@ -92,21 +89,17 @@ def op( |
92 | 89 | bool: True if the operation was applied successfully, False otherwise. |
93 | 90 | """ |
94 | 91 | process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="op") |
95 | | - check_optional_type(label_1, IntegerArray) |
96 | | - check_optional_type(data_1, DoubleArray) |
| 92 | + |
97 | 93 | op = get_enum_value(op, TransformOperations) |
98 | | - check_optional_type(label_2, IntegerArray) |
99 | | - check_optional_type(data_2, DoubleArray) |
100 | | - check_optional_type(label_out, IntegerArray) |
101 | | - check_optional_type(data_out, DoubleArray) |
| 94 | + |
102 | 95 | return self.data_transform.Op( |
103 | | - coerce_optional_dispatch(label_1, "integer_array"), |
104 | | - coerce_optional_dispatch(data_1, "double_array"), |
| 96 | + check_and_coerce_optional(label_1, IntegerArray), |
| 97 | + check_and_coerce_optional(data_1, DoubleArray), |
105 | 98 | op, |
106 | | - coerce_optional_dispatch(label_2, "integer_array"), |
107 | | - coerce_optional_dispatch(data_2, "double_array"), |
108 | | - coerce_optional_dispatch(label_out, "integer_array"), |
109 | | - coerce_optional_dispatch(data_out, "double_array"), |
| 99 | + check_and_coerce_optional(label_2, IntegerArray), |
| 100 | + check_and_coerce_optional(data_2, DoubleArray), |
| 101 | + check_and_coerce_optional(label_out, IntegerArray), |
| 102 | + check_and_coerce_optional(data_out, DoubleArray), |
110 | 103 | ) |
111 | 104 |
|
112 | 105 | # pylint: disable=R0913, R0917 |
@@ -134,17 +127,15 @@ def scalar( |
134 | 127 | bool: True if the scalar operation was applied successfully, False otherwise. |
135 | 128 | """ |
136 | 129 | process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="scalar") |
137 | | - check_optional_type(label_in, IntegerArray) |
138 | | - check_optional_type(data_in, DoubleArray) |
| 130 | + |
139 | 131 | op = get_enum_value(op, TransformScalarOperations) |
140 | 132 | check_type(scalar_value, (float, int)) |
141 | | - check_optional_type(label_out, IntegerArray) |
142 | | - check_optional_type(data_out, DoubleArray) |
| 133 | + |
143 | 134 | return self.data_transform.Scalar( |
144 | | - coerce_optional_dispatch(label_in, "integer_array"), |
145 | | - coerce_optional_dispatch(data_in, "double_array"), |
| 135 | + check_and_coerce_optional(label_in, IntegerArray), |
| 136 | + check_and_coerce_optional(data_in, DoubleArray), |
146 | 137 | op, |
147 | 138 | scalar_value, |
148 | | - coerce_optional_dispatch(label_out, "integer_array"), |
149 | | - coerce_optional_dispatch(data_out, "double_array"), |
| 139 | + check_and_coerce_optional(label_out, IntegerArray), |
| 140 | + check_and_coerce_optional(data_out, DoubleArray), |
150 | 141 | ) |
0 commit comments