Skip to content
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
6 changes: 4 additions & 2 deletions src/ansys/dpf/core/dpf_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,9 @@ def eval(self, pin=None):
if output._pin == pin:
return output()

def _find_outputs_corresponding_pins(self, type_names, inpt, pin, corresponding_pins):
def _find_outputs_corresponding_pins(
self, type_names, inpt, pin, corresponding_pins, input_type_name
):
from ansys.dpf.core.results import Result

for python_name in type_names:
Expand All @@ -827,7 +829,7 @@ def _find_outputs_corresponding_pins(self, type_names, inpt, pin, corresponding_
python_name = "bool"

# Type match
if type(inpt).__name__ == python_name:
if input_type_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)):
Expand Down
9 changes: 7 additions & 2 deletions src/ansys/dpf/core/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
inpt = inpt.value

input_type_name = type(inpt).__name__
if input_type_name == "list":
input_type_name = f"list[{type(inpt[0]).__name__}]"
if not (input_type_name in self._python_expected_types or ["Outputs", "Output", "Any"]):
for types in self._python_expected_types:
print(types, end=" ")
Expand All @@ -114,7 +116,7 @@

corresponding_pins = []
self._operator()._find_outputs_corresponding_pins(
self._python_expected_types, inpt, self._pin, corresponding_pins
self._python_expected_types, inpt, self._pin, corresponding_pins, input_type_name
)
if len(corresponding_pins) > 1:
err_str = "Pin connection is ambiguous, specify the input to connect to with:\n"
Expand All @@ -132,7 +134,7 @@

if len(corresponding_pins) == 0:
err_str = (
f"The input operator for the {self._spec.name} pin must be "
f"The input for the {self._spec.name} pin is of type {input_type_name} but must be "
"one of the following types:\n"
)
err_str += "\n".join([f"- {py_type}" for py_type in self._python_expected_types])
Expand Down Expand Up @@ -260,12 +262,15 @@
inpt = inpt.value

input_type_name = type(inpt).__name__
if input_type_name == "list":
input_type_name = f"list[{type(inpt[0]).__name__}]"

Check warning on line 266 in src/ansys/dpf/core/inputs.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/inputs.py#L266

Added line #L266 was not covered by tests
for input_pin in self._inputs:
self._operator()._find_outputs_corresponding_pins(
input_pin._python_expected_types,
inpt,
input_pin._pin,
corresponding_pins,
input_type_name,
)
if len(corresponding_pins) > 1:
err_str = "Pin connection is ambiguous, specify the input to connect to with:\n"
Expand Down
5 changes: 4 additions & 1 deletion src/ansys/dpf/core/mapping_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,8 @@ def __missing__(self, key):
map_types_to_python = _smart_dict_snake()
for k, v in map_types_to_cpp.items():
map_types_to_python[v] = k
map_types_to_python["vector<double>"] = "list"
map_types_to_python["vector<bool>"] = "list[bool]"
map_types_to_python["vector<int32>"] = "list[int]"
map_types_to_python["vector<double>"] = "list[float]"
map_types_to_python["vector<string>"] = "list[str]"
map_types_to_python["b"] = "bool"
Loading