Skip to content
Closed
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
11 changes: 10 additions & 1 deletion src/ansys/dpf/core/dpf_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,16 @@ def connect(self, pin, inpt, pin_out=0):
self._api.operator_connect_operator_output(self, pin, inpt._operator, inpt._pin)
elif isinstance(inpt, list):
from ansys.dpf.core import collection


# If a list of strings, convert to StringField?
if all(isinstance(s, str) for s in inpt):
from ansys.dpf.core import StringField

string_field = StringField(nentities=len(inpt), server=self._server)
for i, s in enumerate(inpt):
string_field.append([s], i)
self._api.operator_connect_string_field(self, pin, string_field)
return
if server_meet_version("3.0", self._server):
inpt = collection.CollectionBase.integral_collection(inpt, self._server)
self._api.operator_connect_collection_as_vector(self, pin, inpt)
Expand Down
7 changes: 6 additions & 1 deletion src/ansys/dpf/core/mesh_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@
==========
"""

from __future__ import annotations
from ansys.dpf.core import server as server_module
from ansys.dpf.core.generic_data_container import GenericDataContainer
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from ansys.dpf.core import PropertyField

Check warning on line 34 in src/ansys/dpf/core/mesh_info.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/mesh_info.py#L34

Added line #L34 was not covered by tests


class MeshInfo:
Expand Down Expand Up @@ -143,7 +148,7 @@
mesh_info.generic_data_container = self._generic_data_container.deep_copy(server)
return mesh_info

def get_property(self, property_name):
def get_property(self, property_name: str) -> PropertyField:
"""Get property with given name.

Parameters
Expand Down
10 changes: 10 additions & 0 deletions tests/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@ def test_connect_label_space_operator(server_type):
op.connect(0, dic)


@pytest.mark.skipif(
not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
reason="Copying data is " "supported starting server version 5.0",
)
def test_connect_string_list_as_string_field_operator(server_type):
op = dpf.core.Operator("Rescope", server=server_type)
string_list = ["test1", "test2"]
op.connect(0, string_list)


def test_connect_datasources_operator(fields_container_csv, server_type):
op = dpf.core.Operator("csv_to_field", server=server_type)
data_sources = dpf.core.DataSources(server=server_type)
Expand Down
Loading