Skip to content

Commit

Permalink
refactor: Clean-up PyFluent Enums. (#3254)
Browse files Browse the repository at this point in the history
* refactor: Clean-up PyFluent Enums.

* Comparison for UIMode.

* '-' -> '_' in Fluent Enum names.

* Remove comparison operator from UIMode.
  • Loading branch information
prmukherj authored Sep 3, 2024
1 parent 3a49c7d commit 2fcfb38
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 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 @@ -50,7 +50,7 @@ def _raise_non_gui_exception_in_windows(

if (
launcher_utils.is_windows()
and ui_mode < UIMode.HIDDEN_GUI
and UIMode(ui_mode) not in [UIMode.GUI and UIMode.HIDDEN_GUI]
and product_version < FluentVersion.v241
):
raise InvalidArgument(
Expand Down
27 changes: 6 additions & 21 deletions src/ansys/fluent/core/launcher/pyfluent_enums.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Provides a module for enums used in the PyFluent."""

from enum import Enum
from functools import total_ordering
import os
from typing import Optional, Union

Expand All @@ -17,7 +16,6 @@
import ansys.platform.instancemanagement as pypim


@total_ordering
class FluentEnum(Enum):
"""Provides the base class for Fluent-related enums.
Expand Down Expand Up @@ -58,19 +56,6 @@ def is_int():
f""" The supported values are: {msg}."""
)

def __lt__(self, other):
if not isinstance(other, type(self)):
raise TypeError(
f"Cannot compare between {type(self).__name__} and {type(other).__name__}"
)
if self == other:
return False
for member in type(self):
if self == member:
return True
if other == member:
return False


class LaunchMode(FluentEnum):
"""Enumerates over supported Fluent launch modes."""
Expand All @@ -93,9 +78,9 @@ class FluentMode(FluentEnum):
"""Enumerates over supported Fluent modes."""

MESHING = "meshing"
PURE_MESHING = "pure-meshing"
PURE_MESHING = "pure_meshing"
SOLVER = "solver"
SOLVER_ICING = "solver-icing"
SOLVER_ICING = "solver_icing"

def _default(self):
return self.SOLVER
Expand Down Expand Up @@ -129,10 +114,10 @@ def is_meshing(mode: "FluentMode") -> bool:
class UIMode(FluentEnum):
"""Provides supported user interface mode of Fluent."""

NO_GUI_OR_GRAPHICS = "no-gui-or-graphics"
NO_GRAPHICS = "no-graphics"
NO_GUI = "no-gui"
HIDDEN_GUI = "hidden-gui"
NO_GUI_OR_GRAPHICS = "no_gui_or_graphics"
NO_GRAPHICS = "no_graphics"
NO_GUI = "no_gui"
HIDDEN_GUI = "hidden_gui"
GUI = "gui"

def _default(self):
Expand Down
1 change: 0 additions & 1 deletion tests/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ def test_fluent_enums():
assert UIMode("gui") == UIMode.GUI
with pytest.raises(ValueError):
UIMode("")
assert UIMode.NO_GUI < UIMode.GUI
with pytest.raises(TypeError):
UIMode.NO_GUI < FluentWindowsGraphicsDriver.AUTO

Expand Down

0 comments on commit 2fcfb38

Please sign in to comment.