Skip to content

Commit 2fc4911

Browse files
authored
Publish 0.3.1 (#349)
* CompositeFiles: convert rst always into a list. (#347) * improve descriptions * Pump version to 0.3.1
1 parent df99db3 commit 2fc4911

File tree

6 files changed

+46
-14
lines changed

6 files changed

+46
-14
lines changed

README.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ PyDPF Composites
3333
:alt: Black
3434

3535

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

@@ -196,3 +197,4 @@ released versions.
196197
.. _tox: https://tox.wiki/
197198
.. _Examples: https://composites.dpf.docs.pyansys.com/dev/examples/index.html
198199
.. _Getting The DPF Server Docker Image: https://composites.dpf.docs.pyansys.com/version/stable/intro.html#getting-the-dpf-server-docker-image
200+
.. _Ansys DPF: https://dpf.docs.pyansys.com/version/stable/

doc/source/index.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
PyDPF Composites
1212
----------------
1313

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

2021
.. grid:: 1 1 2 2
@@ -73,3 +74,4 @@ Limitations
7374
.. _Ansys Workbench: https://download.ansys.com/Current%20Release
7475
.. _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
7576
.. _Compatibility: https://dpf.docs.pyansys.com/version/stable/getting_started/compatibility.html
77+
.. _Ansys DPF: https://dpf.docs.pyansys.com/version/stable/

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ build-backend = "poetry.core.masonry.api"
55
[tool.poetry]
66
# Check https://python-poetry.org/docs/pyproject/ for all available sections
77
name = "ansys-dpf-composites"
8-
version = "0.3.0"
9-
description = "A python wrapper for ansys dpf composites"
8+
version = "0.3.1"
9+
description = "Post-processing of composite structures based on Ansys DPF"
1010
license = "MIT"
1111
authors = ["ANSYS, Inc. <[email protected]>"]
1212
maintainers = ["PyAnsys developers <[email protected]>"]

src/ansys/dpf/composites/data_sources.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,25 @@ def __init__(
7575
True if files are on the local machine, False if they have already
7676
been uploaded to the DPF server..
7777
"""
78-
if isinstance(rst, (str, pathlib.Path)):
79-
rst = [rst]
8078
self.rst = rst # type: ignore
8179
self.composite = composite
8280
self.engineering_data = engineering_data
8381
self.files_are_local = files_are_local
8482

83+
# The constructor pretends that rst can also be just a path
84+
# but the property rst must be a list
85+
def __setattr__(self, prop, val): # type: ignore
86+
"""Convert values if needed."""
87+
if prop == "rst":
88+
val = self._get_rst_list(val)
89+
super().__setattr__(prop, val)
90+
91+
@staticmethod
92+
def _get_rst_list(value: Union[List[_PATH], _PATH]) -> List[_PATH]:
93+
if isinstance(value, (str, pathlib.Path)):
94+
value = [value]
95+
return value # type: ignore
96+
8597

8698
@dataclass
8799
class ShortFiberCompositesFiles:
@@ -116,13 +128,25 @@ def __init__(
116128
True if files are on the local machine, False if they have already
117129
been uploaded to the DPF server..
118130
"""
119-
if isinstance(rst, (str, pathlib.Path)):
120-
rst = [rst]
121131
self.rst = rst # type: ignore
122132
self.dsdat = dsdat
123133
self.engineering_data = engineering_data
124134
self.files_are_local = files_are_local
125135

136+
# The constructor pretends that rst can also be just a path
137+
# but the property rst must be a list.
138+
def __setattr__(self, prop, val): # type: ignore
139+
"""Convert values if needed."""
140+
if prop == "rst":
141+
val = self._get_rst_list(val)
142+
super().__setattr__(prop, val)
143+
144+
@staticmethod
145+
def _get_rst_list(value: Union[List[_PATH], _PATH]) -> List[_PATH]:
146+
if isinstance(value, (str, pathlib.Path)):
147+
value = [value]
148+
return value # type: ignore
149+
126150

127151
# roosre June 2023: todo add deprecation warning where composite definition label is used
128152
@dataclass(frozen=True)

tests/test_data_sources.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ def test_get_files_from_result_folder_harmonic(dpf_server):
5757

5858
assert files.rst == [WORKFLOW_EXAMPLE_ROOT_HARMONIC / "file.rst"]
5959
assert files.engineering_data == WORKFLOW_EXAMPLE_ROOT_HARMONIC / "MatML.xml"
60+
61+
# ensure that the setter of RST converts the input into a list
62+
files.rst = WORKFLOW_EXAMPLE_ROOT_HARMONIC / "file.rst"
63+
assert files.rst == [WORKFLOW_EXAMPLE_ROOT_HARMONIC / "file.rst"]

tests/test_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33

44
def test_pkg_version():
5-
assert __version__ == "0.3.0"
5+
assert __version__ == "0.3.1"

0 commit comments

Comments
 (0)