ToolComponent
mdo_framework.core.components.ToolComponent
Bases: Discipline
GEMSEO discipline that wraps a Python function.
The function is called with keyword arguments only, one per input. It returns
a dict keyed by output name, or a bare value when the tool has a single
output; a list or an array is a vector value of a single output, a tuple is
never accepted. Anything else, a non-finite value included, is a
ToolOutputError; an exception raised by the function becomes a
ToolExecutionError. Two inputs cannot be passed as the same argument.
Jacobians are approximated by finite differences.
Source code in src/mdo_framework/core/components.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
__init__(name, func, inputs, outputs, *, specs=None, defaults=None, deterministic=True, arg_map=None)
Initializes the tool component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the discipline. |
required |
func
|
Callable[..., Any]
|
The Python callable executing the tool logic. |
required |
inputs
|
Sequence[str]
|
Input variable names. |
required |
outputs
|
Sequence[str]
|
Output variable names. |
required |
specs
|
Mapping[str, ParameterDefinition] | None
|
Parameter definitions per input name, used to decode choice
indices and integers before calling |
None
|
defaults
|
Mapping[str, Any] | None
|
Value of the inputs that may be omitted when executing, per input name. An input without a default is required. |
None
|
deterministic
|
bool
|
Whether the same inputs always give the same outputs. If false, the discipline is never cached. |
True
|
arg_map
|
Mapping[str, str] | None
|
Python argument name per input name, for the inputs whose argument is named differently. |
None
|
Source code in src/mdo_framework/core/components.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
linearize(input_data=READ_ONLY_EMPTY_DICT, compute_all_jacobians=False, execute=True)
Approximates the Jacobian at input_data by finite differences.
GEMSEO's finite differences only perturb the differentiated inputs and
take the others from the defaults, which a design variable lacks. They are
taken from input_data for the duration of the call instead.
Source code in src/mdo_framework/core/components.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |