-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
56 changed files
with
1,151 additions
and
313 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
246 changes: 246 additions & 0 deletions
246
src/ansys/dpf/core/operators/logic/identical_string_fields.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,246 @@ | ||
""" | ||
identical_string_fields | ||
======================= | ||
Autogenerated DPF operator classes. | ||
""" | ||
from warnings import warn | ||
from ansys.dpf.core.dpf_operator import Operator | ||
from ansys.dpf.core.inputs import Input, _Inputs | ||
from ansys.dpf.core.outputs import Output, _Outputs | ||
from ansys.dpf.core.operators.specification import PinSpecification, Specification | ||
|
||
|
||
class identical_string_fields(Operator): | ||
"""Takes two string fields and compares them. | ||
Parameters | ||
---------- | ||
string_fieldA : StringField | ||
string_fieldB : StringField | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> # Instantiate operator | ||
>>> op = dpf.operators.logic.identical_string_fields() | ||
>>> # Make input connections | ||
>>> my_string_fieldA = dpf.StringField() | ||
>>> op.inputs.string_fieldA.connect(my_string_fieldA) | ||
>>> my_string_fieldB = dpf.StringField() | ||
>>> op.inputs.string_fieldB.connect(my_string_fieldB) | ||
>>> # Instantiate operator and connect inputs in one line | ||
>>> op = dpf.operators.logic.identical_string_fields( | ||
... string_fieldA=my_string_fieldA, | ||
... string_fieldB=my_string_fieldB, | ||
... ) | ||
>>> # Get output data | ||
>>> result_are_identical = op.outputs.are_identical() | ||
>>> result_information = op.outputs.information() | ||
""" | ||
|
||
def __init__( | ||
self, string_fieldA=None, string_fieldB=None, config=None, server=None | ||
): | ||
super().__init__(name="compare::string_field", config=config, server=server) | ||
self._inputs = InputsIdenticalStringFields(self) | ||
self._outputs = OutputsIdenticalStringFields(self) | ||
if string_fieldA is not None: | ||
self.inputs.string_fieldA.connect(string_fieldA) | ||
if string_fieldB is not None: | ||
self.inputs.string_fieldB.connect(string_fieldB) | ||
|
||
@staticmethod | ||
def _spec(): | ||
description = """Takes two string fields and compares them.""" | ||
spec = Specification( | ||
description=description, | ||
map_input_pin_spec={ | ||
0: PinSpecification( | ||
name="string_fieldA", | ||
type_names=["string_field"], | ||
optional=False, | ||
document="""""", | ||
), | ||
1: PinSpecification( | ||
name="string_fieldB", | ||
type_names=["string_field"], | ||
optional=False, | ||
document="""""", | ||
), | ||
}, | ||
map_output_pin_spec={ | ||
0: PinSpecification( | ||
name="are_identical", | ||
type_names=["bool"], | ||
optional=False, | ||
document="""""", | ||
), | ||
1: PinSpecification( | ||
name="information", | ||
type_names=["string"], | ||
optional=False, | ||
document="""""", | ||
), | ||
}, | ||
) | ||
return spec | ||
|
||
@staticmethod | ||
def default_config(server=None): | ||
"""Returns the default config of the operator. | ||
This config can then be changed to the user needs and be used to | ||
instantiate the operator. The Configuration allows to customize | ||
how the operation will be processed by the operator. | ||
Parameters | ||
---------- | ||
server : server.DPFServer, optional | ||
Server with channel connected to the remote or local instance. When | ||
``None``, attempts to use the global server. | ||
""" | ||
return Operator.default_config(name="compare::string_field", server=server) | ||
|
||
@property | ||
def inputs(self): | ||
"""Enables to connect inputs to the operator | ||
Returns | ||
-------- | ||
inputs : InputsIdenticalStringFields | ||
""" | ||
return super().inputs | ||
|
||
@property | ||
def outputs(self): | ||
"""Enables to get outputs of the operator by evaluating it | ||
Returns | ||
-------- | ||
outputs : OutputsIdenticalStringFields | ||
""" | ||
return super().outputs | ||
|
||
|
||
class InputsIdenticalStringFields(_Inputs): | ||
"""Intermediate class used to connect user inputs to | ||
identical_string_fields operator. | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.logic.identical_string_fields() | ||
>>> my_string_fieldA = dpf.StringField() | ||
>>> op.inputs.string_fieldA.connect(my_string_fieldA) | ||
>>> my_string_fieldB = dpf.StringField() | ||
>>> op.inputs.string_fieldB.connect(my_string_fieldB) | ||
""" | ||
|
||
def __init__(self, op: Operator): | ||
super().__init__(identical_string_fields._spec().inputs, op) | ||
self._string_fieldA = Input( | ||
identical_string_fields._spec().input_pin(0), 0, op, -1 | ||
) | ||
self._inputs.append(self._string_fieldA) | ||
self._string_fieldB = Input( | ||
identical_string_fields._spec().input_pin(1), 1, op, -1 | ||
) | ||
self._inputs.append(self._string_fieldB) | ||
|
||
@property | ||
def string_fieldA(self): | ||
"""Allows to connect string_fieldA input to the operator. | ||
Parameters | ||
---------- | ||
my_string_fieldA : StringField | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.logic.identical_string_fields() | ||
>>> op.inputs.string_fieldA.connect(my_string_fieldA) | ||
>>> # or | ||
>>> op.inputs.string_fieldA(my_string_fieldA) | ||
""" | ||
return self._string_fieldA | ||
|
||
@property | ||
def string_fieldB(self): | ||
"""Allows to connect string_fieldB input to the operator. | ||
Parameters | ||
---------- | ||
my_string_fieldB : StringField | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.logic.identical_string_fields() | ||
>>> op.inputs.string_fieldB.connect(my_string_fieldB) | ||
>>> # or | ||
>>> op.inputs.string_fieldB(my_string_fieldB) | ||
""" | ||
return self._string_fieldB | ||
|
||
|
||
class OutputsIdenticalStringFields(_Outputs): | ||
"""Intermediate class used to get outputs from | ||
identical_string_fields operator. | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.logic.identical_string_fields() | ||
>>> # Connect inputs : op.inputs. ... | ||
>>> result_are_identical = op.outputs.are_identical() | ||
>>> result_information = op.outputs.information() | ||
""" | ||
|
||
def __init__(self, op: Operator): | ||
super().__init__(identical_string_fields._spec().outputs, op) | ||
self._are_identical = Output( | ||
identical_string_fields._spec().output_pin(0), 0, op | ||
) | ||
self._outputs.append(self._are_identical) | ||
self._information = Output(identical_string_fields._spec().output_pin(1), 1, op) | ||
self._outputs.append(self._information) | ||
|
||
@property | ||
def are_identical(self): | ||
"""Allows to get are_identical output of the operator | ||
Returns | ||
---------- | ||
my_are_identical : bool | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.logic.identical_string_fields() | ||
>>> # Connect inputs : op.inputs. ... | ||
>>> result_are_identical = op.outputs.are_identical() | ||
""" # noqa: E501 | ||
return self._are_identical | ||
|
||
@property | ||
def information(self): | ||
"""Allows to get information output of the operator | ||
Returns | ||
---------- | ||
my_information : str | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.logic.identical_string_fields() | ||
>>> # Connect inputs : op.inputs. ... | ||
>>> result_information = op.outputs.information() | ||
""" # noqa: E501 | ||
return self._information |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.