Skip to content

Commit 6ebe243

Browse files
authored
Add flake8 checks (#30)
* Fix blank lines and whitespace * Add flake8 configuration * Add flake8 to style CI
1 parent 73840d6 commit 6ebe243

File tree

16 files changed

+42
-40
lines changed

16 files changed

+42
-40
lines changed

.flake8

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[flake8]
2+
# To be added once code is refactored: E501, W291, W293, F401
3+
select = W191, W391, E115, E117, E122, E124, E125, E225, E231, E301, E303, F403
4+
count = True
5+
max-complexity = 10
6+
max-line-length = 100
7+
statistics = True

.github/workflows/style.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ jobs:
1616
with:
1717
python-version: 3.8
1818

19-
- name: Style
19+
- name: Install style requirements
2020
run: |
2121
pip install -r requirements_style.txt --disable-pip-version-check
22-
make
22+
23+
- name: Codespell
24+
run: |
25+
make codespell
26+
27+
- name: flake8
28+
run: |
29+
make flake8

Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,26 @@ codespell:
1212
@echo "Running codespell"
1313
@codespell $(CODESPELL_DIRS) -S $(CODESPELL_SKIP) -I $(CODESPELL_IGNORE)
1414

15+
flake8:
16+
@echo "Running flake8"
17+
@flake8 .
18+
1519
pydocstyle:
1620
@echo "Running pydocstyle"
17-
@pydocstyle ansys.mapdl
21+
@pydocstyle ansys.dpf.post
1822

1923
doctest-modules:
2024
@echo "Runnnig module doctesting"
21-
pytest -v --doctest-modules ansys.mapdl
25+
pytest -v --doctest-modules ansys.dpf.post
2226

2327
coverage:
2428
@echo "Running coverage"
25-
@pytest -v --cov ansys.mapdl
29+
@pytest -v --cov ansys.dpf.post
2630

2731
coverage-xml:
2832
@echo "Reporting XML coverage"
29-
@pytest -v --cov ansys.mapdl --cov-report xml
33+
@pytest -v --cov ansys.dpf.post --cov-report xml
3034

3135
coverage-html:
3236
@echo "Reporting HTML coverage"
33-
@pytest -v --cov ansys.mapdl --cov-report html
37+
@pytest -v --cov ansys.dpf.post --cov-report html

ansys/dpf/post/dpf_solution.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _check_nodal_location(self, **kwargs):
6464

6565
def __str__(self):
6666
txt = '%s solution object.' % self._model.metadata.result_info.analysis_type.capitalize() +\
67-
'\n\n\nData Sources\n------------------------------\n'
67+
'\n\n\nData Sources\n------------------------------\n'
6868
ds_str = self._data_sources.__str__()
6969
txt += ds_str
7070
txt += "\n\n"
@@ -184,8 +184,7 @@ def has_complex_result(self):
184184
if (tfq_sup.complex_frequencies == None):
185185
return False
186186
return True
187-
188-
187+
189188
def displacement(self, **kwargs):
190189
"""Returns a displacement object from which it is possible to get ResultData.
191190
@@ -272,8 +271,7 @@ class DpfThermalSolution(DpfSolution):
272271
def __init__(self, data_sources, model):
273272
super().__init__(data_sources, model)
274273
#self.misc = ThermalMisc(model, data_sources)
275-
276-
274+
277275
def __str__(self):
278276
txt = super().__str__()
279277
txt += "\n"

ansys/dpf/post/electric_results.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def __init__(self, **kwargs):
1616
if _AvailableKeywords.element_scoping in kwargs:
1717
raise Exception("Element scoping is not available with thermal/electric results.")
1818
self.definition._Definition__element_scoping_locked = True
19-
2019

2120
def __str__(self):
2221
txt = super().__str__()

ansys/dpf/post/misc_results.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ def modal_basis(self, **kwargs):
127127
self._check_nodal_location(**kwargs)
128128
return self._get_result_data_function_of_operator("ModalBasis", self, self._data_sources, **kwargs)
129129

130-
131130
#element nodal results (get result at nodes or at elements)
132131
def elemental_stress(self, **kwargs):
133132
"""Returns a elemental_stress result data."""
@@ -339,7 +338,6 @@ def nodal_elastic_strain_energy_density(self, **kwargs):
339338
self._check_nodal_location(**kwargs)
340339
return self._get_result_data_function_of_operator("ENL_ELENG", self, self._data_sources, location="Nodal", **kwargs)
341340

342-
343341
#element nodal result (here only elemental result given because the nodal one is given in nodal category)
344342
def elemental_force(self, **kwargs):
345343
"""Returns a elemental_force result data."""
@@ -352,7 +350,6 @@ def elemental_nodal_force(self, **kwargs):
352350
self._check_elemnodal_location(**kwargs)
353351
return self._get_result_data_function_of_operator("ENF", self, self._data_sources, location="ElementalNodal", **kwargs)
354352

355-
356353
#element results
357354
def elemental_contact_status(self, **kwargs):
358355
"""Returns a elemental_contact_status result data."""
@@ -439,7 +436,6 @@ def elemental_thermal_dissipation_energy(self, **kwargs):
439436
self._check_elemental_location(**kwargs)
440437
return self._get_result_data_function_of_operator("ENG_TH", self, self._data_sources, location="Elemental", **kwargs)
441438

442-
443439
#special results
444440
def von_mises_stress(self, **kwargs):
445441
"""von_mises_stress output default location is Nodal.

ansys/dpf/post/result_data.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def __init__(self, operator_name: str, data_sources, model,
5353
location, element_scoping, node_scoping, named_selection, time,
5454
grouping, phase, subresult, mapdl_grouping, set, time_scoping)
5555
self.result_fields_container = None
56-
57-
56+
5857
def __str__(self):
5958
self._evaluate_result()
6059
name = self.result_fields_container[0].name.split("_")
@@ -178,8 +177,7 @@ def get_min_data_at_field(self, field_index: int = 0):
178177
returns its result (output from pin 0).
179178
"""
180179
return self._min_max(0).data[field_index]
181-
182-
180+
183181
def _plot_contour_with_vtk_file(self):
184182
"""Plot the contour result on its mesh support. The obtained figure depends on the
185183
support (can be a meshed_region or a time_freq_support).
@@ -189,8 +187,7 @@ def _plot_contour_with_vtk_file(self):
189187
self._evaluate_result()
190188
pl = DpfPlotter(self._evaluator._model.metadata.meshed_region)
191189
pl._plot_contour_using_vtk_file(self.result_fields_container)
192-
193-
190+
194191
def plot_contour(self, display_option: str = "time", option_id=1,
195192
off_screen=None, notebook=None, **kwargs):
196193
"""Plot the contour result on its mesh support.

ansys/dpf/post/result_evaluation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __init__(self, operator_name: str, data_sources, model,
7979
if (grouping == Grouping.by_material) or (grouping == Grouping.by_body):
8080
scop_op.inputs.label1.connect("mat")
8181
elif(grouping == Grouping.by_el_shape):
82-
scop_op.inputs.label1.connect("elshape")
82+
scop_op.inputs.label1.connect("elshape")
8383
else:
8484
raise Exception("Grouping impossible. Use the keyword argument as: grouping = grouping.by_el_shape, grouping = grouping.by_material...")
8585
self._result_operator.inputs.mesh_scoping.connect(scop_op.outputs.mesh_scoping)

docs/source/conf.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@
4444
# Add any Sphinx extension module names here, as strings. They can be
4545
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4646
# ones.
47-
extensions = ['sphinx.ext.autodoc',
48-
'sphinx_gallery.gen_gallery',
49-
'sphinx.ext.todo',
50-
'sphinx.ext.napoleon',
47+
extensions = [
48+
'sphinx.ext.autodoc',
49+
'sphinx_gallery.gen_gallery',
50+
'sphinx.ext.todo',
51+
'sphinx.ext.napoleon',
5152
]
5253

5354
autosummary_generate = True
5455

55-
5656
# Add any paths that contain templates here, relative to this directory.
5757
# templates_path = ['_templates']
5858

@@ -107,8 +107,6 @@
107107
# "set_plot_theme('document')"),
108108
}
109109

110-
111-
112110
# -- Options for HTML output -------------------------------------------------
113111

114112
# The theme to use for HTML and HTML Help pages. See the documentation for

examples/01-Different-analysis-types/02-modal-analysis.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,3 @@
110110
###############################################################################
111111
# **It is also possible to deal with plastic_strain and temperature this way.**
112112
# The result file must contain those results.
113-

0 commit comments

Comments
 (0)