Skip to content

Commit 10d3011

Browse files
authored
Cleanup Docs and Prep for CI (#13)
* change module name to ansys-dpf-post * docs cleanup
1 parent c7b7ff5 commit 10d3011

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+706
-567
lines changed

.gitignore

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
#########################
42
## DPF
53
#########################
@@ -20,4 +18,17 @@
2018

2119
#other
2220
/perso
23-
/examples/Jupyter lab/.ipynb_checkpoints
21+
/examples/Jupyter lab/.ipynb_checkpoints
22+
23+
# compiled documentation
24+
docs/_build
25+
docs/source/examples
26+
27+
# pip files
28+
*.egg-info
29+
build/
30+
dist/
31+
32+
# emacs temp files
33+
*~
34+
.#*

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Simple makefile to simplify repetitive build env management tasks under posix
2+
3+
CODESPELL_DIRS ?= ./
4+
CODESPELL_SKIP ?= "*.pyc,*.txt,*.gif,*.png,*.jpg,*.js,*.html,*.doctree,*.ttf,*.woff,*.woff2,*.eot,*.mp4,*.inv,*.pickle,*.ipynb,flycheck*,./.git/*,./.hypothesis/*,*.yml,./docs/_build/*,./docs/images/*,./dist/*,*~,.hypothesis*,./docs/source/examples/*,*cover,*.dat,*.mac,\#*,build,./ansys/dpf/core/raw_operators.py,./run_client.bat,./docker/v211"
5+
CODESPELL_IGNORE ?= "ignore_words.txt"
6+
7+
all: doctest
8+
9+
doctest: codespell
10+
11+
codespell:
12+
@echo "Running codespell"
13+
@codespell $(CODESPELL_DIRS) -S $(CODESPELL_SKIP) -I $(CODESPELL_IGNORE)
14+
15+
pydocstyle:
16+
@echo "Running pydocstyle"
17+
@pydocstyle ansys.mapdl
18+
19+
doctest-modules:
20+
@echo "Runnnig module doctesting"
21+
pytest -v --doctest-modules ansys.mapdl
22+
23+
coverage:
24+
@echo "Running coverage"
25+
@pytest -v --cov ansys.mapdl
26+
27+
coverage-xml:
28+
@echo "Reporting XML coverage"
29+
@pytest -v --cov ansys.mapdl --cov-report xml
30+
31+
coverage-html:
32+
@echo "Reporting HTML coverage"
33+
@pytest -v --cov ansys.mapdl --cov-report html

ansys/dpf/post/displacement.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
"""This module contains the displacement result class ."""
1+
"""This module contains the displacement result class."""
22

33
from ansys.dpf.post.vector import Vector, ComplexVector
44
from ansys.dpf.core import locations
5-
5+
from ansys.dpf.post.errors import NodalLocationError
66

77
class Displacement(Vector):
88
"""Defines the displacement object, that is a vector object."""
@@ -11,7 +11,7 @@ def __init__(self, **kwargs):
1111
self._operator_name = "U"
1212

1313
if self.definition.location != locations.nodal:
14-
raise Exception("The location must be nodal.")
14+
raise NodalLocationError
1515

1616
def __str__(self):
1717
txt = super().__str__()
@@ -27,4 +27,4 @@ def __init__(self, **kwargs):
2727
self._operator_name = "U"
2828

2929
if self.definition.location != locations.nodal:
30-
raise Exception("The location must be nodal.")
30+
raise NodalLocationError

ansys/dpf/post/dpf_solution.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
"""Module containing the DpfSolution class and its childs.
2-
Each class highlights an analysis type, and provides hardcoded
3-
methods to get a result object regarding the wanted result type.
1+
"""Module containing the DpfSolution class and its children. Each class
2+
highlights an analysis type, and provides hard-coded methods to get a
3+
result object regarding the wanted result type.
44
5-
Module containing also the DpfComplexSolution class, child of DpfSolution class.
6-
Additionnaly to the classic APIs, the complex result introduces an amplitude evaluation."""
5+
Module containing also the DpfComplexSolution class, child of
6+
DpfSolution class. In addition to the classic APIs, the complex
7+
result introduces an amplitude evaluation.
8+
"""
79

810

911
from ansys.dpf.post.common import _AvailableKeywords
@@ -168,7 +170,7 @@ def __init__(self, data_sources, model):
168170
def __str__(self):
169171
txt = super().__str__()
170172
txt += "\n"
171-
txt += "This can contain complex result."
173+
txt += "This may contain complex results."
172174
return txt
173175

174176
def has_complex_result(self):
@@ -276,7 +278,7 @@ def __init__(self, data_sources, model):
276278
def __str__(self):
277279
txt = super().__str__()
278280
txt += "\n"
279-
txt += "This can contain complex result."
281+
txt += "This may contain complex results."
280282
return txt
281283

282284
def temperature(self, **kwargs):
@@ -343,4 +345,4 @@ def electric_field(self, **kwargs):
343345
"""
344346
return ElectricField(data_sources=self._data_sources, model=self._model, **kwargs)
345347

346-
348+

ansys/dpf/post/errors.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""DPF-Post specific errors"""
2+
3+
class NodalLocationError(ValueError):
4+
"""Raised when attempting to """
5+
6+
def __init__(self, msg="The location must be nodal."):
7+
ValueError.__init__(self, msg)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""DPF-Post example files"""
2+
from ansys.dpf.core.examples import (
3+
simple_bar,
4+
static_rst,
5+
complex_rst,
6+
multishells_rst,
7+
static_rst,
8+
electric_therm,
9+
steady_therm,
10+
transient_therm,
11+
download_all_kinds_of_complexity_modal,
12+
download_all_kinds_of_complexity,
13+
download_transient_result,
14+
msup_transient,
15+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""DPF-Post example files"""
2+
3+
from ansys.dpf.core.example import *
557 Bytes
Binary file not shown.

ansys/dpf/post/post_utility.py

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,61 @@
1-
"""Module containing the methode to instantiate the result object. Initialization of post objects."""
1+
"""Module containing the method to instantiate the result
2+
object. Initialization of post objects.
3+
"""
24

3-
from ansys.dpf.core.model import Model
5+
from ansys.dpf.core.model import Model
46

57
from ansys.dpf.post.common import _AnalysisType, _AvailableKeywords, _PhysicsType
6-
from ansys.dpf.post.static_analysis import StaticAnalysisSolution, ThermalStaticAnalysisSolution
8+
from ansys.dpf.post.static_analysis import (StaticAnalysisSolution,
9+
ThermalStaticAnalysisSolution)
710
from ansys.dpf.post.modal_analysis import ModalAnalysisSolution
811
from ansys.dpf.post.harmonic_analysis import HarmonicAnalysisSolution
9-
from ansys.dpf.post.transient_analysis import TransientAnalysisSolution, ThermalTransientAnalysisSolution
10-
12+
from ansys.dpf.post.transient_analysis import (TransientAnalysisSolution,
13+
ThermalTransientAnalysisSolution)
14+
1115

1216
def load_solution(data_sources):
13-
"""Return a Result object which can provide information on a given set, on a given scoping...
14-
17+
"""Return a ``Result`` object which can provide information on a given
18+
set, on a given scoping.
19+
1520
Parameters
1621
----------
17-
str
18-
Can be a filepath to the file you want to open, or a dpf.core.DataSources().
19-
22+
data_sources : str or dpf.core.DataSources
23+
filepath to the file you want to open, or a dpf.core.DataSources().
24+
2025
Examples
2126
--------
22-
solution = post.solution("file.rst")
27+
>>> solution = post.solution("file.rst")
2328
"""
2429
_model = Model(data_sources)
2530
data_sources = _model.metadata.data_sources
26-
31+
2732
analysis_type = _model.metadata.result_info.analysis_type
2833
physics_type = _model.metadata.result_info.physics_type
29-
if (physics_type == _PhysicsType.thermal):
30-
if(analysis_type == _AnalysisType.static):
31-
return ThermalStaticAnalysisSolution(data_sources, _model)
32-
elif (analysis_type == _AnalysisType.transient):
34+
if physics_type == _PhysicsType.thermal:
35+
if analysis_type == _AnalysisType.static:
36+
return ThermalStaticAnalysisSolution(data_sources, _model)
37+
elif analysis_type == _AnalysisType.transient:
3338
return ThermalTransientAnalysisSolution(data_sources, _model)
3439
else:
35-
raise Exception("Unknown analysis type.")
36-
elif (physics_type == _PhysicsType.mecanic):
37-
if(analysis_type == _AnalysisType.static):
40+
raise Exception(f"Unknown analysis type '{analysis_type}' for thermal.")
41+
elif physics_type == _PhysicsType.mecanic:
42+
if analysis_type == _AnalysisType.static:
3843
return StaticAnalysisSolution(data_sources, _model)
39-
elif (analysis_type == _AnalysisType.modal):
44+
elif analysis_type == _AnalysisType.modal:
4045
return ModalAnalysisSolution(data_sources, _model)
41-
elif (analysis_type == _AnalysisType.harmonic):
46+
elif analysis_type == _AnalysisType.harmonic:
4247
return HarmonicAnalysisSolution(data_sources, _model)
43-
elif (analysis_type == _AnalysisType.transient):
48+
elif analysis_type == _AnalysisType.transient:
4449
return TransientAnalysisSolution(data_sources, _model)
4550
else:
46-
raise Exception("Unknown analysis type.")
51+
raise Exception(f"Unknown analysis type '{analysis_type}' for mechanical.")
4752
else:
48-
raise Exception("Unknown physics type.")
49-
50-
53+
raise Exception(f"Unknown physics type '{physics_type}.")
54+
55+
5156
def print_available_keywords():
5257
"""Print the keywords that can be used into the result object.
53-
58+
5459
Examples
5560
--------
5661
>>> from ansys.dpf import post
@@ -59,4 +64,3 @@ def print_available_keywords():
5964
"""
6065
txt = _AvailableKeywords().__str__()
6166
print(txt)
62-

0 commit comments

Comments
 (0)