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/4551.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SettingsBase.__call__ should also set state if any argument is passed.
31 changes: 17 additions & 14 deletions src/ansys/fluent/core/solver/flobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,9 +819,14 @@ def to_python_keys(cls, value: StateT) -> StateT:
"""
return value

def __call__(self) -> StateT:
"""Alias for self.get_state."""
return self.get_state()
def __call__(self, *args, **kwargs):
"""Get or set the state of the object."""
if kwargs:
self.set_state(kwargs)
elif args:
self.set_state(args)
else:
return self.get_state()

def get_state(self) -> StateT:
"""Get the state of the object."""
Expand Down Expand Up @@ -1065,14 +1070,6 @@ def __init__(self, name: str | None = None, parent=None):
cls = self.__class__._child_classes[query]
self._setattr(query, _create_child(cls, None, self))

def __call__(self, *args, **kwargs):
if kwargs:
self.set_state(kwargs)
elif args:
self.set_state(args)
else:
return self.get_state()

@classmethod
def to_scheme_keys(cls, value, root_cls, path: list[str]):
"""Convert value to have keys with scheme names.
Expand Down Expand Up @@ -1503,7 +1500,10 @@ def __add__(self, other):

def list(self):
"""Print the object names."""
return self._root.list(object_path=self.path)
if FluentVersion(self._version) >= FluentVersion.v261:
return self._root.list(object_path=self.path)
else:
return self.list_1()

def list_properties(self, object_name):
"""Print the properties of the given object name.
Expand All @@ -1513,8 +1513,11 @@ def list_properties(self, object_name):
object_name : str
Name of the object whose properties are to be listed.
"""
# The generated parameter name is path_1 as the name path clashes with existing property.
return self._root.list_properties(path_1=self.path, name=object_name)
if FluentVersion(self._version) >= FluentVersion.v261:
# The generated parameter name is path_1 as the name path clashes with existing property.
return self._root.list_properties(path_1=self.path, name=object_name)
else:
return self.list_properties_1(object_name=object_name)


class CombinedNamedObject:
Expand Down
51 changes: 26 additions & 25 deletions tests/test_flobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,34 +1223,35 @@ def test_default_argument_names_for_commands(static_mixer_settings_session):
solver = static_mixer_settings_session

if solver.get_fluent_version() >= FluentVersion.v251:
assert set(solver.results.graphics.contour.command_names) == {
"create",
"delete",
"rename",
"list",
"list_properties",
"make_a_copy",
"display",
"add_to_graphics",
"clear_history",
}
assert set(solver.results.graphics.contour.command_names).issuperset(
{
"create",
"delete",
"rename",
"make_a_copy",
"display",
"add_to_graphics",
"clear_history",
}
)
else:
assert set(solver.results.graphics.contour.command_names) == {
"delete",
"rename",
"list",
"list_properties",
"make_a_copy",
"display",
"copy",
"add_to_graphics",
"clear_history",
}
assert set(solver.results.graphics.contour.command_names).issuperset(
{
"delete",
"rename",
"make_a_copy",
"display",
"copy",
"add_to_graphics",
"clear_history",
}
)

assert solver.results.graphics.contour.rename.argument_names == ["new", "old"]
assert set(solver.results.graphics.contour.rename.argument_names) == {"new", "old"}
assert solver.results.graphics.contour.delete.argument_names == ["name_list"]
# The following is the default behavior when no arguments are associated with the command.
assert solver.results.graphics.contour.list.argument_names == []
if solver.get_fluent_version() < FluentVersion.v261:
# The following is the default behavior when no arguments are associated with the command.
assert solver.results.graphics.contour.list_1.argument_names == []


@pytest.mark.fluent_version(">=25.1")
Expand Down