|
20 | 20 | _FrozenDiscreteModel,
|
21 | 21 | _FrozenContinuousModel,
|
22 | 22 | )
|
23 |
| -from ... import errors, utils |
24 |
| -from ...operators import ( |
25 |
| - OperatorTemplate, |
26 |
| - ParametricOperatorTemplate, |
27 |
| - InterpConstantOperator, |
28 |
| - InterpLinearOperator, |
29 |
| - InterpQuadraticOperator, |
30 |
| - InterpCubicOperator, |
31 |
| - InterpInputOperator, |
32 |
| - InterpStateInputOperator, |
33 |
| - _utils as oputils, |
34 |
| -) |
35 |
| - |
36 |
| - |
37 |
| -_operator_name2class = { |
38 |
| - OpClass.__name__: OpClass |
39 |
| - for OpClass in ( |
40 |
| - InterpConstantOperator, |
41 |
| - InterpLinearOperator, |
42 |
| - InterpQuadraticOperator, |
43 |
| - InterpCubicOperator, |
44 |
| - InterpInputOperator, |
45 |
| - InterpStateInputOperator, |
46 |
| - ) |
47 |
| -} |
| 23 | +from ... import errors, utils, operators as _operators |
| 24 | +from ...operators import _utils as oputils |
48 | 25 |
|
49 | 26 |
|
50 | 27 | # Base classes ================================================================
|
@@ -82,8 +59,8 @@ def _isvalidoperator(self, op):
|
82 | 59 | return isinstance(
|
83 | 60 | op,
|
84 | 61 | (
|
85 |
| - OperatorTemplate, |
86 |
| - ParametricOperatorTemplate, |
| 62 | + _operators.OperatorTemplate, |
| 63 | + _operators.ParametricOperatorTemplate, |
87 | 64 | ),
|
88 | 65 | )
|
89 | 66 |
|
@@ -1124,12 +1101,12 @@ def set_interpolator(self, InterpolatorClass):
|
1124 | 1101 |
|
1125 | 1102 | # Properties: operators ---------------------------------------------------
|
1126 | 1103 | _operator_abbreviations = {
|
1127 |
| - "c": InterpConstantOperator, |
1128 |
| - "A": InterpLinearOperator, |
1129 |
| - "H": InterpQuadraticOperator, |
1130 |
| - "G": InterpCubicOperator, |
1131 |
| - "B": InterpInputOperator, |
1132 |
| - "N": InterpStateInputOperator, |
| 1104 | + "c": _operators.InterpConstantOperator, |
| 1105 | + "A": _operators.InterpLinearOperator, |
| 1106 | + "H": _operators.InterpQuadraticOperator, |
| 1107 | + "G": _operators.InterpCubicOperator, |
| 1108 | + "B": _operators.InterpInputOperator, |
| 1109 | + "N": _operators.InterpStateInputOperator, |
1133 | 1110 | }
|
1134 | 1111 |
|
1135 | 1112 | def _isvalidoperator(self, op):
|
@@ -1317,11 +1294,8 @@ def load(cls, loadfile: str, InterpolatorClass: type = None):
|
1317 | 1294 | for i in range(num_operators):
|
1318 | 1295 | gp = hf[f"operator_{i}"]
|
1319 | 1296 | OpClassName = gp["meta"].attrs["class"]
|
1320 |
| - ops.append( |
1321 |
| - _operator_name2class[OpClassName].load( |
1322 |
| - gp, InterpolatorClass |
1323 |
| - ) |
1324 |
| - ) |
| 1297 | + OpClass = getattr(_operators, OpClassName) |
| 1298 | + ops.append(OpClass.load(gp, InterpolatorClass)) |
1325 | 1299 |
|
1326 | 1300 | # Construct the model.
|
1327 | 1301 | model = cls(ops)
|
|
0 commit comments