Skip to content

Commit

Permalink
fix: fix minor issues in settings and fluent version. (#3276)
Browse files Browse the repository at this point in the history
* refactor: fix minor issues in settings and fluent version.

* fix_test.

* Add test.
  • Loading branch information
prmukherj authored Sep 9, 2024
1 parent aaf0fa4 commit ecf0749
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/launcher/error_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _raise_non_gui_exception_in_windows(
and product_version < FluentVersion.v241
):
raise InvalidArgument(
f"'{ui_mode}' supported in Windows only for Fluent version 24.1 or later."
f"'{ui_mode}' supported in Windows only for {str(FluentVersion.v241)} or later."
)


Expand Down
8 changes: 6 additions & 2 deletions src/ansys/fluent/core/solver/flobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import weakref
from zipimport import zipimporter

from ansys.fluent.core.utils.fluent_version import FluentVersion
from ansys.fluent.core.warnings import PyFluentDeprecationWarning, PyFluentUserWarning

from .flunits import UnhandledQuantity, get_si_unit_for_fluent_quantity
Expand Down Expand Up @@ -291,7 +292,10 @@ def python_path(self) -> str:
Constructed in python syntax from 'python_path' and the parents python path.
"""
if self._parent is None:
return "<session>"
if FluentVersion(self.flproxy._scheme_eval.version).number < 251:
return "<session>"
else:
return "<session>.settings"
ppath = self._parent.python_path
if not ppath:
return self.python_name
Expand Down Expand Up @@ -723,7 +727,7 @@ def set_state(self, state: Optional[StateT] = None, **kwargs):
self.value.set_state(state, **kwargs)
else:
state = self._unalias(kwargs or state)
return self.flproxy.set_var(self.path, self.to_scheme_keys(state))
self.flproxy.set_var(self.path, self.to_scheme_keys(state))

@staticmethod
def _print_state_helper(state, out, indent=0, indent_factor=2):
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/systemcoupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, solver):
# version check - this requires Fluent 2024 R1 or newer.
if self._solver.get_fluent_version() < FluentVersion.v241:
raise RuntimeError(
f"Fluent version is {self._solver.get_fluent_version().value}. PySystemCoupling integration requires Fluent {FluentVersion.v241.value} or later."
f"Using {str(self._solver.get_fluent_version())}. PySystemCoupling integration requires {str(FluentVersion.v241)} or later."
)

@property
Expand Down
6 changes: 6 additions & 0 deletions src/ansys/fluent/core/utils/fluent_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,9 @@ def __lt__(self, other):
def __repr__(self) -> str:
"""Return a string representation for the Fluent version."""
return self.value

def __str__(self) -> str:
"""String output for the Fluent version."""
return (
f"Fluent version 20{self.value.split('.')[0]} R{self.value.split('.')[1]}"
)
5 changes: 5 additions & 0 deletions tests/test_flobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,18 @@ def cb(self, a1, a2):
}


class _SchemeEval:
version = "25.1.0"


class Proxy:
"""Proxy class."""

root = Root

def __init__(self):
self.r = self.root(None)
self._scheme_eval = _SchemeEval()

def get_obj(self, path):
if not path:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_fluent_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,8 @@ def test_ne():
def test_eq():
assert FluentVersion.v232 == FluentVersion.v232
assert FluentVersion.v241 == FluentVersion.v241


def test_str_output():
assert str(FluentVersion.v232) == "Fluent version 2023 R2"
assert str(FluentVersion.v251) == "Fluent version 2025 R1"

0 comments on commit ecf0749

Please sign in to comment.