|
| 1 | +""" |
| 2 | +customtypefield_get_attribute |
| 3 | +
|
| 4 | +Autogenerated DPF operator classes. |
| 5 | +""" |
| 6 | + |
| 7 | +from __future__ import annotations |
| 8 | + |
| 9 | +from warnings import warn |
| 10 | +from ansys.dpf.core.dpf_operator import Operator |
| 11 | +from ansys.dpf.core.inputs import Input, _Inputs |
| 12 | +from ansys.dpf.core.outputs import Output, _Outputs |
| 13 | +from ansys.dpf.core.outputs import _modify_output_spec_with_one_type |
| 14 | +from ansys.dpf.core.operators.specification import PinSpecification, Specification |
| 15 | +from ansys.dpf.core.config import Config |
| 16 | +from ansys.dpf.core.server_types import AnyServerType |
| 17 | + |
| 18 | + |
| 19 | +class customtypefield_get_attribute(Operator): |
| 20 | + r"""A CustomTypeField in pin 0 and a property name (string) in pin 1 are |
| 21 | + expected in input. |
| 22 | +
|
| 23 | +
|
| 24 | + Parameters |
| 25 | + ---------- |
| 26 | + custom_type_field: CustomTypeField |
| 27 | + property_name: str |
| 28 | + Accepted inputs are: 'time_freq_support', 'scoping' and 'header'. |
| 29 | +
|
| 30 | + Returns |
| 31 | + ------- |
| 32 | + property: TimeFreqSupport or Scoping or DataTree |
| 33 | + Property value. |
| 34 | +
|
| 35 | + Examples |
| 36 | + -------- |
| 37 | + >>> from ansys.dpf import core as dpf |
| 38 | +
|
| 39 | + >>> # Instantiate operator |
| 40 | + >>> op = dpf.operators.utility.customtypefield_get_attribute() |
| 41 | +
|
| 42 | + >>> # Make input connections |
| 43 | + >>> my_custom_type_field = dpf.CustomTypeField() |
| 44 | + >>> op.inputs.custom_type_field.connect(my_custom_type_field) |
| 45 | + >>> my_property_name = str() |
| 46 | + >>> op.inputs.property_name.connect(my_property_name) |
| 47 | +
|
| 48 | + >>> # Instantiate operator and connect inputs in one line |
| 49 | + >>> op = dpf.operators.utility.customtypefield_get_attribute( |
| 50 | + ... custom_type_field=my_custom_type_field, |
| 51 | + ... property_name=my_property_name, |
| 52 | + ... ) |
| 53 | +
|
| 54 | + >>> # Get output data |
| 55 | + >>> result_property = op.outputs.property() |
| 56 | + """ |
| 57 | + |
| 58 | + def __init__( |
| 59 | + self, custom_type_field=None, property_name=None, config=None, server=None |
| 60 | + ): |
| 61 | + super().__init__( |
| 62 | + name="customtypefield::get_attribute", config=config, server=server |
| 63 | + ) |
| 64 | + self._inputs = InputsCustomtypefieldGetAttribute(self) |
| 65 | + self._outputs = OutputsCustomtypefieldGetAttribute(self) |
| 66 | + if custom_type_field is not None: |
| 67 | + self.inputs.custom_type_field.connect(custom_type_field) |
| 68 | + if property_name is not None: |
| 69 | + self.inputs.property_name.connect(property_name) |
| 70 | + |
| 71 | + @staticmethod |
| 72 | + def _spec() -> Specification: |
| 73 | + description = r"""A CustomTypeField in pin 0 and a property name (string) in pin 1 are |
| 74 | +expected in input. |
| 75 | +""" |
| 76 | + spec = Specification( |
| 77 | + description=description, |
| 78 | + map_input_pin_spec={ |
| 79 | + 0: PinSpecification( |
| 80 | + name="custom_type_field", |
| 81 | + type_names=["custom_type_field"], |
| 82 | + optional=False, |
| 83 | + document=r"""""", |
| 84 | + ), |
| 85 | + 1: PinSpecification( |
| 86 | + name="property_name", |
| 87 | + type_names=["string"], |
| 88 | + optional=False, |
| 89 | + document=r"""Accepted inputs are: 'time_freq_support', 'scoping' and 'header'.""", |
| 90 | + ), |
| 91 | + }, |
| 92 | + map_output_pin_spec={ |
| 93 | + 0: PinSpecification( |
| 94 | + name="property", |
| 95 | + type_names=["time_freq_support", "scoping", "abstract_data_tree"], |
| 96 | + optional=False, |
| 97 | + document=r"""Property value.""", |
| 98 | + ), |
| 99 | + }, |
| 100 | + ) |
| 101 | + return spec |
| 102 | + |
| 103 | + @staticmethod |
| 104 | + def default_config(server: AnyServerType = None) -> Config: |
| 105 | + """Returns the default config of the operator. |
| 106 | +
|
| 107 | + This config can then be changed to the user needs and be used to |
| 108 | + instantiate the operator. The Configuration allows to customize |
| 109 | + how the operation will be processed by the operator. |
| 110 | +
|
| 111 | + Parameters |
| 112 | + ---------- |
| 113 | + server: |
| 114 | + Server with channel connected to the remote or local instance. When |
| 115 | + ``None``, attempts to use the global server. |
| 116 | +
|
| 117 | + Returns |
| 118 | + ------- |
| 119 | + config: |
| 120 | + A new Config instance equivalent to the default config for this operator. |
| 121 | + """ |
| 122 | + return Operator.default_config( |
| 123 | + name="customtypefield::get_attribute", server=server |
| 124 | + ) |
| 125 | + |
| 126 | + @property |
| 127 | + def inputs(self) -> InputsCustomtypefieldGetAttribute: |
| 128 | + """Enables to connect inputs to the operator |
| 129 | +
|
| 130 | + Returns |
| 131 | + -------- |
| 132 | + inputs: |
| 133 | + An instance of InputsCustomtypefieldGetAttribute. |
| 134 | + """ |
| 135 | + return super().inputs |
| 136 | + |
| 137 | + @property |
| 138 | + def outputs(self) -> OutputsCustomtypefieldGetAttribute: |
| 139 | + """Enables to get outputs of the operator by evaluating it |
| 140 | +
|
| 141 | + Returns |
| 142 | + -------- |
| 143 | + outputs: |
| 144 | + An instance of OutputsCustomtypefieldGetAttribute. |
| 145 | + """ |
| 146 | + return super().outputs |
| 147 | + |
| 148 | + |
| 149 | +class InputsCustomtypefieldGetAttribute(_Inputs): |
| 150 | + """Intermediate class used to connect user inputs to |
| 151 | + customtypefield_get_attribute operator. |
| 152 | +
|
| 153 | + Examples |
| 154 | + -------- |
| 155 | + >>> from ansys.dpf import core as dpf |
| 156 | + >>> op = dpf.operators.utility.customtypefield_get_attribute() |
| 157 | + >>> my_custom_type_field = dpf.CustomTypeField() |
| 158 | + >>> op.inputs.custom_type_field.connect(my_custom_type_field) |
| 159 | + >>> my_property_name = str() |
| 160 | + >>> op.inputs.property_name.connect(my_property_name) |
| 161 | + """ |
| 162 | + |
| 163 | + def __init__(self, op: Operator): |
| 164 | + super().__init__(customtypefield_get_attribute._spec().inputs, op) |
| 165 | + self._custom_type_field = Input( |
| 166 | + customtypefield_get_attribute._spec().input_pin(0), 0, op, -1 |
| 167 | + ) |
| 168 | + self._inputs.append(self._custom_type_field) |
| 169 | + self._property_name = Input( |
| 170 | + customtypefield_get_attribute._spec().input_pin(1), 1, op, -1 |
| 171 | + ) |
| 172 | + self._inputs.append(self._property_name) |
| 173 | + |
| 174 | + @property |
| 175 | + def custom_type_field(self) -> Input: |
| 176 | + r"""Allows to connect custom_type_field input to the operator. |
| 177 | +
|
| 178 | + Returns |
| 179 | + ------- |
| 180 | + input: |
| 181 | + An Input instance for this pin. |
| 182 | +
|
| 183 | + Examples |
| 184 | + -------- |
| 185 | + >>> from ansys.dpf import core as dpf |
| 186 | + >>> op = dpf.operators.utility.customtypefield_get_attribute() |
| 187 | + >>> op.inputs.custom_type_field.connect(my_custom_type_field) |
| 188 | + >>> # or |
| 189 | + >>> op.inputs.custom_type_field(my_custom_type_field) |
| 190 | + """ |
| 191 | + return self._custom_type_field |
| 192 | + |
| 193 | + @property |
| 194 | + def property_name(self) -> Input: |
| 195 | + r"""Allows to connect property_name input to the operator. |
| 196 | +
|
| 197 | + Accepted inputs are: 'time_freq_support', 'scoping' and 'header'. |
| 198 | +
|
| 199 | + Returns |
| 200 | + ------- |
| 201 | + input: |
| 202 | + An Input instance for this pin. |
| 203 | +
|
| 204 | + Examples |
| 205 | + -------- |
| 206 | + >>> from ansys.dpf import core as dpf |
| 207 | + >>> op = dpf.operators.utility.customtypefield_get_attribute() |
| 208 | + >>> op.inputs.property_name.connect(my_property_name) |
| 209 | + >>> # or |
| 210 | + >>> op.inputs.property_name(my_property_name) |
| 211 | + """ |
| 212 | + return self._property_name |
| 213 | + |
| 214 | + |
| 215 | +class OutputsCustomtypefieldGetAttribute(_Outputs): |
| 216 | + """Intermediate class used to get outputs from |
| 217 | + customtypefield_get_attribute operator. |
| 218 | +
|
| 219 | + Examples |
| 220 | + -------- |
| 221 | + >>> from ansys.dpf import core as dpf |
| 222 | + >>> op = dpf.operators.utility.customtypefield_get_attribute() |
| 223 | + >>> # Connect inputs : op.inputs. ... |
| 224 | + >>> result_property = op.outputs.property() |
| 225 | + """ |
| 226 | + |
| 227 | + def __init__(self, op: Operator): |
| 228 | + super().__init__(customtypefield_get_attribute._spec().outputs, op) |
| 229 | + self.property_as_time_freq_support = Output( |
| 230 | + _modify_output_spec_with_one_type( |
| 231 | + customtypefield_get_attribute._spec().output_pin(0), "time_freq_support" |
| 232 | + ), |
| 233 | + 0, |
| 234 | + op, |
| 235 | + ) |
| 236 | + self._outputs.append(self.property_as_time_freq_support) |
| 237 | + self.property_as_scoping = Output( |
| 238 | + _modify_output_spec_with_one_type( |
| 239 | + customtypefield_get_attribute._spec().output_pin(0), "scoping" |
| 240 | + ), |
| 241 | + 0, |
| 242 | + op, |
| 243 | + ) |
| 244 | + self._outputs.append(self.property_as_scoping) |
| 245 | + self.property_as_data_tree = Output( |
| 246 | + _modify_output_spec_with_one_type( |
| 247 | + customtypefield_get_attribute._spec().output_pin(0), "data_tree" |
| 248 | + ), |
| 249 | + 0, |
| 250 | + op, |
| 251 | + ) |
| 252 | + self._outputs.append(self.property_as_data_tree) |
0 commit comments