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