Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/error accessing attrribute file type #705

Merged
merged 4 commits into from
Aug 11, 2022
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
16 changes: 12 additions & 4 deletions src/ansys/fluent/core/solver/flobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ def is_active(self) -> bool:
"""Whether the object is active."""
return self.get_attr("active?")

def is_read_only(self) -> bool:
"""Whether the object is read-only."""
return self.get_attr("read-only?")

def __setattr__(self, name, value):
raise AttributeError(name)

Expand All @@ -170,10 +174,6 @@ def default_value(self):
"""Gets the default value of the object."""
return self.get_attr("default")

def is_read_only(self) -> bool:
"""Whether the object is read-only."""
return self.get_attr("read-only?")


class Numerical(Property):
"""Exposes attribute accessor on settings object - specific to numerical objects."""
Expand Down Expand Up @@ -668,6 +668,14 @@ def _get_new_keywords(obj, kwds):
class Command(Base):
"""Command object."""

def __init__(self, name: str = None, parent=None):
"""__init__ of Command class."""
super().__init__(name, parent)
if hasattr(self, "argument_names"):
for argument in self.argument_names:
cls = getattr(self.__class__, argument)
self._setattr(argument, cls(None, self))

def __call__(self, **kwds):
"""Call a command with the specified keyword arguments."""
newkwds = _get_new_keywords(self, kwds)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_flobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,3 +631,13 @@ class a_2(Boolean):
fluent_name = "a-2"
'''
) # noqa: W293


def test_accessor_methods_on_settings_object(sample_solver_session):
existing = sample_solver_session.file.read.file_type.get_attr("allowed-values")
modified = sample_solver_session.file.read.file_type.allowed_values()
assert existing == modified

existing = sample_solver_session.file.read.file_type.get_attr("read-only?")
modified = sample_solver_session.file.read.file_type.is_read_only()
assert existing == modified
7 changes: 7 additions & 0 deletions tests/util/fixture_fluent.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,10 @@ def get_name_info(allnamesdict, namescheck):
if name in details.values() or name in details or name in names:
name_selected[name] = details
return name_selected


@pytest.fixture
def sample_solver_session(with_launching_container):
solver_session = pyfluent.launch_fluent(mode="solver")
yield solver_session
solver_session.exit()