Skip to content

Commit

Permalink
Publish 0.3.1 (#349)
Browse files Browse the repository at this point in the history
* CompositeFiles: convert rst always into a list. (#347)

* improve descriptions

* Pump version to 0.3.1
  • Loading branch information
roosre authored Sep 14, 2023
1 parent df99db3 commit 2fc4911
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 14 deletions.
12 changes: 7 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ PyDPF Composites
:alt: Black


PyDPF Composites is a Python wrapper for Ansys DPF composites. It implements
classes on top of DPF Composites operators and data accessors for short
fiber and layered composites (layered shell and solid elements). This module
can be used to postprocess fiber reinforced plastics and layered composites and
to implement custom failure criteria and computation. For information demonstrating
PyDPF Composites enables the post-processing of composite structures based on
`Ansys DPF`_ and the DPF Composites plugin. It implements classes on top of
DPF Composites operators and data accessors for short fiber and layered
composites (layered shell and solid elements). This module can be used to
postprocess fiber reinforced plastics and layered composites, and to implement
custom failure criteria and computation. For information demonstrating
the behavior and usage of PyDPF Composites, see `Examples`_ in the DPF Composite
documentation.

Expand Down Expand Up @@ -196,3 +197,4 @@ released versions.
.. _tox: https://tox.wiki/
.. _Examples: https://composites.dpf.docs.pyansys.com/dev/examples/index.html
.. _Getting The DPF Server Docker Image: https://composites.dpf.docs.pyansys.com/version/stable/intro.html#getting-the-dpf-server-docker-image
.. _Ansys DPF: https://dpf.docs.pyansys.com/version/stable/
6 changes: 4 additions & 2 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
PyDPF Composites
----------------

PyDPF Composites is a Python wrapper for Ansys DPF composites. It implements
PyDPF Composites enables the post-processing of composite structures based on
`Ansys DPF`_ and the DPF Composites plugin. It implements
classes on top of DPF Composites operators and data accessors for short
fiber and layered composites (layered shell and solid elements). This module
can be used to postprocess fiber reinforced plastics and layered composites and
can be used to postprocess fiber reinforced plastics and layered composites, and
to implement custom failure criteria and computation.

.. grid:: 1 1 2 2
Expand Down Expand Up @@ -73,3 +74,4 @@ Limitations
.. _Ansys Workbench: https://download.ansys.com/Current%20Release
.. _Import of Legacy Mechanical APDL Composite Models: https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v231/en/acp_ug/acp_import_legacy_APDL_comp.html
.. _Compatibility: https://dpf.docs.pyansys.com/version/stable/getting_started/compatibility.html
.. _Ansys DPF: https://dpf.docs.pyansys.com/version/stable/
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
# Check https://python-poetry.org/docs/pyproject/ for all available sections
name = "ansys-dpf-composites"
version = "0.3.0"
description = "A python wrapper for ansys dpf composites"
version = "0.3.1"
description = "Post-processing of composite structures based on Ansys DPF"
license = "MIT"
authors = ["ANSYS, Inc. <[email protected]>"]
maintainers = ["PyAnsys developers <[email protected]>"]
Expand Down
32 changes: 28 additions & 4 deletions src/ansys/dpf/composites/data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,25 @@ def __init__(
True if files are on the local machine, False if they have already
been uploaded to the DPF server..
"""
if isinstance(rst, (str, pathlib.Path)):
rst = [rst]
self.rst = rst # type: ignore
self.composite = composite
self.engineering_data = engineering_data
self.files_are_local = files_are_local

# The constructor pretends that rst can also be just a path
# but the property rst must be a list
def __setattr__(self, prop, val): # type: ignore
"""Convert values if needed."""
if prop == "rst":
val = self._get_rst_list(val)
super().__setattr__(prop, val)

@staticmethod
def _get_rst_list(value: Union[List[_PATH], _PATH]) -> List[_PATH]:
if isinstance(value, (str, pathlib.Path)):
value = [value]
return value # type: ignore


@dataclass
class ShortFiberCompositesFiles:
Expand Down Expand Up @@ -116,13 +128,25 @@ def __init__(
True if files are on the local machine, False if they have already
been uploaded to the DPF server..
"""
if isinstance(rst, (str, pathlib.Path)):
rst = [rst]
self.rst = rst # type: ignore
self.dsdat = dsdat
self.engineering_data = engineering_data
self.files_are_local = files_are_local

# The constructor pretends that rst can also be just a path
# but the property rst must be a list.
def __setattr__(self, prop, val): # type: ignore
"""Convert values if needed."""
if prop == "rst":
val = self._get_rst_list(val)
super().__setattr__(prop, val)

@staticmethod
def _get_rst_list(value: Union[List[_PATH], _PATH]) -> List[_PATH]:
if isinstance(value, (str, pathlib.Path)):
value = [value]
return value # type: ignore


# roosre June 2023: todo add deprecation warning where composite definition label is used
@dataclass(frozen=True)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ def test_get_files_from_result_folder_harmonic(dpf_server):

assert files.rst == [WORKFLOW_EXAMPLE_ROOT_HARMONIC / "file.rst"]
assert files.engineering_data == WORKFLOW_EXAMPLE_ROOT_HARMONIC / "MatML.xml"

# ensure that the setter of RST converts the input into a list
files.rst = WORKFLOW_EXAMPLE_ROOT_HARMONIC / "file.rst"
assert files.rst == [WORKFLOW_EXAMPLE_ROOT_HARMONIC / "file.rst"]
2 changes: 1 addition & 1 deletion tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


def test_pkg_version():
assert __version__ == "0.3.0"
assert __version__ == "0.3.1"

0 comments on commit 2fc4911

Please sign in to comment.