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

Feat flobj combined #868

Merged
merged 15 commits into from
Sep 12, 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
13 changes: 7 additions & 6 deletions src/ansys/fluent/core/solver/flobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from typing import Any, Dict, Generic, List, NewType, Tuple, TypeVar, Union
import weakref

from ansys.fluent.core.utils.logging import LOG
from .logging import LOG

# Type hints
RealType = NewType("real", Union[float, str]) # constant or expression
Expand Down Expand Up @@ -146,7 +146,7 @@ def get_attr(self, attr) -> Any:
attrs = self.get_attrs([attr])
if attr != "active?" and attrs.get("active?", True) is False:
raise RuntimeError("Object is not active")
return attrs[attr]
return attrs[attr] if attrs else None

def is_active(self) -> bool:
"""Whether the object is active."""
Expand Down Expand Up @@ -369,10 +369,11 @@ def __init__(self, name: str = None, parent=None):

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

@classmethod
def to_scheme_keys(cls, value):
Expand Down Expand Up @@ -862,7 +863,7 @@ def get_cls(name, info, parent=None):
dct["__doc__"] = f"'{pname.strip('_')}' child."

include_child_named_objects = info.get("include_child_named_objects", False)
user_creatable = info.get("user_creatable", True)
user_creatable = info.get("user_creatable", False)

bases = (base,)
if include_child_named_objects:
Expand Down
1 change: 1 addition & 0 deletions src/ansys/fluent/core/solver/logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ansys.fluent.core.utils.logging import LOG # noqa: F401
24 changes: 24 additions & 0 deletions tests/test_creatable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest
from util.solver_workflow import new_solver_session # noqa: F401


@pytest.mark.fluent_231
def test_creatable(new_solver_session) -> None:

has_not = (
new_solver_session.setup.boundary_conditions.velocity_inlet,
new_solver_session.setup.cell_zone_conditions.fluid,
)

has = (
new_solver_session.results.graphics.contour,
new_solver_session.results.graphics.vector,
)

for obj in has_not:
assert not hasattr(obj, "create")
assert "create" not in dir(obj)

for obj in has:
assert hasattr(obj, "create")
assert "create" in dir(obj)