Skip to content

Fix connecting Any as inpt #1991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/ansys/dpf/core/dpf_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,10 @@ def _find_outputs_corresponding_pins(self, type_names, inpt, pin, corresponding_
if python_name == "B":
python_name = "bool"

# Type match
if type(inpt).__name__ == python_name:
corresponding_pins.append(pin)
# if the inpt has multiple potential outputs, find which ones can match
elif isinstance(inpt, (_Outputs, Operator, Result)):
if isinstance(inpt, Operator):
output_pin_available = inpt.outputs._get_given_output([python_name])
Expand All @@ -840,12 +842,14 @@ def _find_outputs_corresponding_pins(self, type_names, inpt, pin, corresponding_
output_pin_available = inpt._get_given_output([python_name])
for outputpin in output_pin_available:
corresponding_pins.append((pin, outputpin))
# If any output type matches python_name
elif isinstance(inpt, Output):
for inpttype in inpt._python_expected_types:
if inpttype == python_name:
corresponding_pins.append(pin)
if python_name == "Any":
corresponding_pins.append(pin)
else:
for inpttype in inpt._python_expected_types:
if inpttype == python_name:
corresponding_pins.append(pin)
elif python_name == "Any":
corresponding_pins.append(pin)

Expand Down
6 changes: 6 additions & 0 deletions tests/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,3 +1496,9 @@ def test_operator_id(server_type):
assert op.id not in ids

ids.add(op.id)


def test_operator_find_outputs_corresponding_pins_any(server_type):
f1 = ops.utility.forward()
f2 = ops.utility.forward()
f2.inputs.any.connect(f1.outputs.any)
Loading