Skip to content

Commit

Permalink
doc: first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
moe-ad committed Dec 23, 2024
1 parent deb24c5 commit ef14a0f
Show file tree
Hide file tree
Showing 47 changed files with 92 additions and 130 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ indent-style = "space"
[tool.ruff.lint]
select = [
# "E", # pycodestyle, see https://beta.ruff.rs/docs/rules/#pycodestyle-e-w
# "D", # pydocstyle, see https://beta.ruff.rs/docs/rules/#pydocstyle-d
"D", # pydocstyle, see https://beta.ruff.rs/docs/rules/#pydocstyle-d
# "F", # pyflakes, see https://beta.ruff.rs/docs/rules/#pyflakes-f
# "I", # isort, see https://beta.ruff.rs/docs/rules/#isort-i
# "N", # pep8-naming, see https://beta.ruff.rs/docs/rules/#pep8-naming-n
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""Version for ansys-dpf-core"""
"""Version for ansys-dpf-core."""

# Minimal DPF server version supported
min_server_version = "4.0"
Expand Down
5 changes: 3 additions & 2 deletions src/ansys/dpf/core/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""Module contains the function for modal animation creation."""

import ansys.dpf.core as dpf
import numpy as np

Expand All @@ -34,8 +36,7 @@ def animate_mode(
**kwargs,
):
# other option: instead of `type` use `min_factor` and `max_factor`.

"""Creates a modal animation based on Fields contained in the FieldsContainer.
"""Create a modal animation based on Fields contained in the FieldsContainer.
This method creates a movie or a gif based on the time ids of a ``FieldsContainer``.
For kwargs see pyvista.Plotter.open_movie/add_text/show.
Expand Down
22 changes: 17 additions & 5 deletions src/ansys/dpf/core/animator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# SOFTWARE.

"""
Animator
Animator.
This module contains the DPF animator class.
Expand All @@ -37,16 +37,15 @@


class _InternalAnimatorFactory:
"""
Factory for _InternalAnimator based on the backend."""
"""Factory for _InternalAnimator based on the backend."""

@staticmethod
def get_animator_class():
return _PyVistaAnimator


class _PyVistaAnimator(_PyVistaPlotter):
"""This _InternalAnimator class is based on PyVista"""
"""An InternalAnimator class based on PyVista."""

def __init__(self, **kwargs):
super().__init__(**kwargs)
Expand Down Expand Up @@ -190,6 +189,8 @@ def animation():


class Animator:
"""The DPF animator class."""

def __init__(self, workflow=None, **kwargs):
"""
Create an Animator object.
Expand Down Expand Up @@ -228,6 +229,7 @@ def __init__(self, workflow=None, **kwargs):
def workflow(self) -> core.Workflow:
"""
Workflow used to generate a Field at each frame of the animation.
By default, the "to_render" Field output will be plotted,
and the "loop_over" input defines what the animation iterates on.
Optionally, the workflow can also have a "deform_by" Field output,
Expand Down Expand Up @@ -267,7 +269,7 @@ def animate(
**kwargs,
):
"""
Animate the workflow of the Animator, using inputs
Animate the workflow of the Animator, using inputs.
Parameters
----------
Expand Down Expand Up @@ -316,6 +318,16 @@ def animate(


def scale_factor_to_fc(scale_factor, fc):
"""Scale the fields being animated by a factor.
Parameters
----------
scale_factor : int, float, list
Scale factor to apply to the animated field.
fc : FieldsContainer
FieldsContainer containing the fields being animated.
"""

def int_to_field(value, shape, scoping):
field = core.fields_factory.field_from_array(np.full(shape=shape, fill_value=value))
field.scoping = scoping
Expand Down
2 changes: 0 additions & 2 deletions src/ansys/dpf/core/any.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ def new_from(obj, server=None):
any : Any
Wrapped any type.
"""

inner_server = server if server is not None else obj._server

if not inner_server.meet_version("7.0"):
Expand Down Expand Up @@ -295,7 +294,6 @@ def cast(self, output_type=None):
type
Original object instance
"""

self._internal_type = output_type if output_type is not None else self._internal_type

type_tuple = self._type_to_new_from_get_as_method(self._internal_type)
Expand Down
2 changes: 0 additions & 2 deletions src/ansys/dpf/core/check_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def server_meet_version_and_raise(required_version, server, msg=None):
bool
``True`` when successful, ``False`` when failed.
"""

if not server_meet_version(required_version, server):
if msg is not None:
raise dpf_errors.DpfVersionNotSupported(required_version, msg=msg)
Expand Down Expand Up @@ -143,7 +142,6 @@ def decorator(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
"""Call the original function"""

if isinstance(self._server, weakref.ref):
server = self._server()
else:
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/collection_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def _data_processing_core_api(self):
def _add_entry(self, label_space, entry):
"""Update or add an entry at a requested label space.
parameters
Parameters
----------
label_space : list[str,int]
Label space of the requested fields. For example, ``{"time":1, "complex":0}``.
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/dpf/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"""
Common
.. autoclass:: locations
:members:
Expand Down Expand Up @@ -348,7 +347,8 @@ def _common_percentage_progress_bar(text):
class SubClassSmartDict(dict):
def __getitem__(self, item):
"""If found returns the item of key == ìtem`, else returns item with key matching `issubclass(item,
key)`."""
key)`.
"""
if item in self:
return super().__getitem__(item)
else:
Expand Down
10 changes: 5 additions & 5 deletions src/ansys/dpf/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def config_option_value(self, config_name):
Name of the configuration option.
Returns
----------
-------
str
Value for the configuration option.
"""
Expand All @@ -236,7 +236,7 @@ def config_option_documentation(self, config_name):
Name of the configuration option.
Returns
----------
-------
str
Documentation for the configuration option.
"""
Expand All @@ -254,7 +254,7 @@ def config_option_accepted_types(self, config_name):
Name of the configuration option.
Returns
----------
-------
list, str
One or more accepted types for the configuration option.
"""
Expand All @@ -271,7 +271,7 @@ def config_option_default_value(self, config_name):
Name of the configuration option.
Returns
----------
-------
str
Default value for the configuration option.
"""
Expand All @@ -285,7 +285,7 @@ def available_config_options(self):
"""Available configuration options for the operator.
Returns
----------
-------
list, str
One or more available configuration options for the operator.
"""
Expand Down
1 change: 0 additions & 1 deletion src/ansys/dpf/core/custom_fields_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def solid_fields(self, timeid=None, complexid=None):
Examples
--------
>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.download_all_kinds_of_complexity_modal())
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/dpf/core/custom_type_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def location(self, location):
"""Change the field location.
Parameters
-------
----------
location : str or locations
Location string, which can be ``"Nodal"``, ``"Elemental"``,
``"ElementalNodal"``... See :class:`ansys.dpf.core.common.locations`.
Expand Down Expand Up @@ -449,7 +449,7 @@ def unit(self):
"""Units for the field.
Returns
----------
-------
str
Units for the field.
Expand Down
1 change: 0 additions & 1 deletion src/ansys/dpf/core/cyclic_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ def cs(self) -> field.Field:
>>> cs = cyc_support.cs()
"""

cs = self._api.cyclic_support_get_cs(self)
return field.Field(field=cs, server=self._server)

Expand Down
5 changes: 3 additions & 2 deletions src/ansys/dpf/core/data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ def guess_result_key(filepath: str) -> str:
@staticmethod
def guess_second_key(filepath: str) -> str:
"""For files with an h5 or cff extension, look for another extension."""

# These files usually end with .cas.h5 or .dat.h5
accepted = ["cas", "dat"]
new_split = Path(filepath).suffixes
Expand Down Expand Up @@ -233,6 +232,7 @@ def add_file_path(self, filepath, key="", is_domain: bool = False, domain_id=0):
domain_id: int, optional
Domain ID for the distributed files. The default is ``0``. For this
parameter to be taken into account, ``domain_path=True`` must be set.
Examples
--------
>>> from ansys.dpf import core as dpf
Expand Down Expand Up @@ -275,6 +275,7 @@ def add_domain_file_path(self, filepath, key, domain_id):
plugin when a result is requested by an operator.
domain_id:
Domain ID for the distributed files.
Examples
--------
>>> from ansys.dpf import core as dpf
Expand Down Expand Up @@ -378,7 +379,7 @@ def result_files(self):
"""List of result files contained in the data sources.
Returns
----------
-------
list
List of result files.
"""
Expand Down
1 change: 0 additions & 1 deletion src/ansys/dpf/core/dpf_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
DPFArray
.. autoclass:: DPFArray
:members:
Expand Down
16 changes: 8 additions & 8 deletions src/ansys/dpf/core/dpf_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ def _add_sub_res_operators(self, sub_results):
>>> disp_z = model.results.displacement().Z()
"""

for result_type in sub_results:
try:
setattr(
Expand All @@ -235,7 +234,8 @@ def _outputs(self, value):
@version_requires("3.0")
def progress_bar(self) -> bool:
"""With this property, the user can choose to print a progress bar when
the operator's output is requested, default is False"""
the operator's output is requested, default is False
"""
return self._progress_bar

@progress_bar.setter
Expand Down Expand Up @@ -316,6 +316,7 @@ def connect(self, pin, inpt, pin_out=0):
@version_requires("6.2")
def connect_operator_as_input(self, pin, op):
"""Connects an operator as an input on a pin.
Parameters
----------
pin : int
Expand Down Expand Up @@ -630,7 +631,7 @@ def config(self):
For information on an operator's options, see the documentation for that operator.
Returns
----------
-------
:class:`ansys.dpf.core.config.Config`
Copy of the operator's current configuration.
Expand Down Expand Up @@ -691,7 +692,7 @@ def inputs(self):
"""Inputs connected to the operator.
Returns
--------
-------
:class:`ansys.dpf.core.inputs`
Inputs connected to the operator.
Expand All @@ -706,15 +707,14 @@ def inputs(self):
>>> disp_op.inputs.data_sources(data_src)
"""

return self._inputs

@property
def outputs(self):
"""Outputs from the operator's evaluation.
Returns
--------
-------
:class:`ansys.dpf.core.outputs`
Outputs from the operator's evaluation.
Expand Down Expand Up @@ -811,7 +811,6 @@ def eval(self, pin=None):
>>> normfc = math.norm_fc(disp_op).eval()
"""

if not pin:
if self.outputs != None and len(self.outputs._outputs) > 0:
return self.outputs._outputs[0]()
Expand Down Expand Up @@ -919,7 +918,8 @@ def __mul__(self, value):
@staticmethod
def operator_specification(op_name, server=None):
"""Documents an Operator with its description (what the Operator does),
its inputs and outputs and some properties"""
its inputs and outputs and some properties
"""
return Specification(operator_name=op_name, server=server)

@property
Expand Down
Loading

0 comments on commit ef14a0f

Please sign in to comment.