From 2167d17fcc9da357cfc2c1ffff8fd5aebd8defdc Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Fri, 10 Oct 2025 08:32:30 -0400 Subject: [PATCH 1/5] fix: SettingsBase.__call__ should also set state if any argument is passed. --- src/ansys/fluent/core/solver/flobject.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/ansys/fluent/core/solver/flobject.py b/src/ansys/fluent/core/solver/flobject.py index 2661366eaee..2d7b79d8a85 100644 --- a/src/ansys/fluent/core/solver/flobject.py +++ b/src/ansys/fluent/core/solver/flobject.py @@ -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.""" @@ -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. From c3a5984afb0dedb8a6e4152775dd28d30266cc6f Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Tue, 21 Oct 2025 14:32:43 -0400 Subject: [PATCH 2/5] fix: test --- tests/test_flobject.py | 50 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/test_flobject.py b/tests/test_flobject.py index ff513b2d5bb..bfc17656cda 100644 --- a/tests/test_flobject.py +++ b/tests/test_flobject.py @@ -1223,34 +1223,34 @@ 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).issuperset( + {"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 == [] @pytest.mark.fluent_version(">=25.1") From a5a665a8385d5361c6587f8231ec42d981307fcc Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Tue, 21 Oct 2025 16:01:29 -0400 Subject: [PATCH 3/5] fix: test --- src/ansys/fluent/core/solver/flobject.py | 12 +++++++++--- tests/test_flobject.py | 7 ++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/ansys/fluent/core/solver/flobject.py b/src/ansys/fluent/core/solver/flobject.py index 2d7b79d8a85..b1c62878000 100644 --- a/src/ansys/fluent/core/solver/flobject.py +++ b/src/ansys/fluent/core/solver/flobject.py @@ -1500,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. @@ -1510,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) class CombinedNamedObject: diff --git a/tests/test_flobject.py b/tests/test_flobject.py index bfc17656cda..24e60bbd830 100644 --- a/tests/test_flobject.py +++ b/tests/test_flobject.py @@ -1247,10 +1247,11 @@ def test_default_argument_names_for_commands(static_mixer_settings_session): } ) - assert set(solver.results.graphics.contour.rename.argument_names).issuperset( - {"new", "old"} - ) + assert set(solver.results.graphics.contour.rename.argument_names) == {"new", "old"} assert solver.results.graphics.contour.delete.argument_names == ["name_list"] + 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") From 690476d297a6bc7d7c82ada348503f3b94b68118 Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Tue, 21 Oct 2025 16:51:12 -0400 Subject: [PATCH 4/5] fix: test --- src/ansys/fluent/core/solver/flobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/fluent/core/solver/flobject.py b/src/ansys/fluent/core/solver/flobject.py index b1c62878000..3495fde77df 100644 --- a/src/ansys/fluent/core/solver/flobject.py +++ b/src/ansys/fluent/core/solver/flobject.py @@ -1517,7 +1517,7 @@ def list_properties(self, object_name): # 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) + return self.list_properties_1(object_name=object_name) class CombinedNamedObject: From 6a79761a8b4ff7a2a2f01815f224e432d624c701 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Tue, 21 Oct 2025 20:52:46 +0000 Subject: [PATCH 5/5] chore: adding changelog file 4551.fixed.md [dependabot-skip] --- doc/changelog.d/4551.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/4551.fixed.md diff --git a/doc/changelog.d/4551.fixed.md b/doc/changelog.d/4551.fixed.md new file mode 100644 index 00000000000..cda93f7ed6a --- /dev/null +++ b/doc/changelog.d/4551.fixed.md @@ -0,0 +1 @@ +SettingsBase.__call__ should also set state if any argument is passed.