+
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
20 changes: 16 additions & 4 deletions src/ansys/dpf/core/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"""Inputs."""

from textwrap import wrap
import warnings
import weakref

from ansys.dpf import core
Expand Down Expand Up @@ -112,7 +113,7 @@
self._python_expected_types, inpt, self._pin, corresponding_pins
)
if len(corresponding_pins) > 1:
err_str = "Pin connection is ambiguous, specify the pin with:\n"
err_str = "Pin connection is ambiguous, specify the input to connect to with:\n"

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L116 was not covered by tests
for pin in corresponding_pins:
err_str += (
" - operator.inputs."
Expand All @@ -121,7 +122,9 @@
+ inpt._dict_outputs[pin[1]].name
+ ")"
)
raise ValueError(err_str)
err_str += "Connecting to first input in the list.\n"
warnings.warn(message=err_str)
corresponding_pins = [corresponding_pins[0]]

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

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/inputs.py#L125-L127

Added lines #L125 - L127 were not covered by tests

if len(corresponding_pins) == 0:
err_str = (
Expand Down Expand Up @@ -218,13 +221,20 @@

Searches for the input type corresponding to the output.

.. deprecated::
Deprecated in favor of explicit output-to-input connections.

Parameters
----------
inpt : str, int, double, bool, list[int], list[float], Field, FieldsContainer, Scoping,
ScopingsContainer, MeshedRegion, MeshesContainer, DataSources, CyclicSupport, Outputs, os.PathLike # noqa: E501
Input of the operator.

"""
warnings.warn(
message="Use explicit output-to-input connections.", category=DeprecationWarning
)

from pathlib import Path

corresponding_pins = []
Expand All @@ -250,12 +260,14 @@
corresponding_pins,
)
if len(corresponding_pins) > 1:
err_str = "Pin connection is ambiguous, specify the pin with:\n"
err_str = "Pin connection is ambiguous, specify the input to connect to with:\n"

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L263 was not covered by tests
for pin in corresponding_pins:
if isinstance(pin, tuple):
pin = pin[0]
err_str += " - operator.inputs." + self._dict_inputs[pin].name + "(input)\n"
raise ValueError(err_str)
err_str += "Connecting to first input in the list.\n"
warnings.warn(message=err_str)
corresponding_pins = [corresponding_pins[0]]

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

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/inputs.py#L268-L270

Added lines #L268 - L270 were not covered by tests

if len(corresponding_pins) == 0:
err_str = "The input should have one of the expected types:\n"
Expand Down
19 changes: 16 additions & 3 deletions tests/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,11 @@ def test_inputs_outputs_scopings_container(allkindofcomplexity):
assert scop.location == dpf.core.locations.elemental

stress = model.results.stress()
stress.inputs.connect(op.outputs)
with (
# pytest.warns(match="Pin connection is ambiguous"),
pytest.warns(DeprecationWarning, match="Use explicit"),
):
stress.inputs.connect(op.outputs)
fc = stress.outputs.fields_container()
assert fc.labels == ["elshape", "time"]
assert len(fc) == 4
Expand Down Expand Up @@ -589,8 +593,17 @@ def test_inputs_outputs_meshes_container(allkindofcomplexity):
sc = opsc.outputs.mesh_scoping()

stress = model.results.stress()
stress.inputs.connect(op.outputs)
stress.inputs.connect(opsc.outputs)
with (
# pytest.warns(match="Pin connection is ambiguous"),
pytest.warns(DeprecationWarning, match="Use explicit"),
):
stress.inputs.connect(op.outputs)

with (
# pytest.warns(match="Pin connection is ambiguous"),
pytest.warns(DeprecationWarning, match="Use explicit"),
):
stress.inputs.connect(opsc.outputs)
fc = stress.outputs.fields_container()
assert fc.labels == ["body", "elshape", "time"]
assert len(fc) == 4
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载