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
1 change: 1 addition & 0 deletions doc/changelog.d/4382.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Textual type in flobject.
13 changes: 13 additions & 0 deletions src/ansys/fluent/core/solver/flobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
FluentFieldDataNamingStrategy as naming_strategy,
)
import ansys.units
from ansys.units import VariableDescriptor

from . import _docstrings
from ..pyfluent_warnings import warning_for_fluent_dev_version
Expand Down Expand Up @@ -676,7 +677,19 @@ def set_state(self, state: StateT | None = None, **kwargs):
Either str or VariableDescriptor.
kwargs : Any
Keyword arguments.

Raises
------
TypeError
If state is not a string.
"""
allowed_types = (str, VariableDescriptor)

if not isinstance(state, allowed_types):
expected = " or ".join(t.__name__ for t in allowed_types)
raise TypeError(
f"Expected state to be {expected}, got {type(state).__name__}."
)
return self.base_set_state(state=_to_field_name_str(state), **kwargs)


Expand Down