Skip to content

Commit 7341032

Browse files
authored
refactor and use pre-commit (#137)
* refactor and use pre-commit * cleanup readme * fix flake8 * add coverage * remove example test
1 parent 50dc6bf commit 7341032

Some content is hidden

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

63 files changed

+5327
-4137
lines changed

.codespellrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[codespell]
2+
skip = *.pyc,*.txt,*.gif,*.png,*.jpg,*.js,*.html,*.doctree,*.ttf,*.woff,*.woff2,*.eot,*.mp4,*.inv,*.pickle,*.ipynb,flycheck*,./.git/*,./.hypothesis/*,*.yml,./doc/build/*,./doc/images/*,./dist/*,*~,.hypothesis*,./doc/source/examples/*,*cover,*.dat,*.mac,\#*,build,./docker/mapdl/v*,./factory/*,./ansys/mapdl/core/mapdl_functions.py,PKG-INFO,*.mypy_cache/*,./docker/mapdl/*,./_unused/*
3+
ignore-words-list = delet,appen,parm,pres,wan,filname,ans,tread,wan,levl,mater,aadd,extrem,imagin,ist,nin,sord,struc,emiss,vise,sur,ect,ther,esy
4+
quiet-level = 3

.flake8

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[flake8]
2+
exclude = venv, __init__.py, build, doc/source/examples
3+
# To be added after refactoring code to be compliant: E501
4+
select = W191, W291, W293, W391, E115, E117, E122, E124, E125, E225, E231, E301, E303, F401, F403
5+
count = True
6+
max-complexity = 10
7+
max-line-length = 100
8+
statistics = True

.github/workflows/testing-and-deployment.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ jobs:
199199
if: ${{ runner.os == 'Windows' }}
200200
run: pytest -v tests/ --durations=0
201201

202+
- uses: codecov/codecov-action@v2
203+
if: ${{ runner.os == 'Linux' && runner.python-version == '3.9' }}
204+
name: 'Upload coverage to Codecov'
205+
202206
- name: Upload wheel
203207
uses: actions/upload-artifact@v2
204208
with:

.pre-commit-config.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 22.3.0
4+
hooks:
5+
- id: black
6+
7+
- repo: https://github.com/pycqa/isort
8+
rev: 5.10.1
9+
hooks:
10+
- id: isort
11+
args: [
12+
"--profile", "black",
13+
"--force-sort-within-sections",
14+
"--skip-glob", "*__init__.py",
15+
]
16+
- repo: https://gitlab.com/PyCQA/flake8
17+
rev: 3.9.2
18+
hooks:
19+
- id: flake8
20+
21+
- repo: https://github.com/codespell-project/codespell
22+
rev: v2.1.0
23+
hooks:
24+
- id: codespell
25+
26+
# add this eventually
27+
# - repo: https://github.com/pycqa/pydocstyle
28+
# rev: 6.1.1
29+
# hooks:
30+
# - id: pydocstyle
31+
# additional_dependencies: [toml]
32+
# exclude: "tests/"
33+
34+
- repo: https://github.com/pre-commit/pre-commit-hooks
35+
rev: v4.1.0
36+
hooks:
37+
- id: check-merge-conflict
38+
- id: debug-statements
39+
40+
# this validates our github workflow files
41+
- repo: https://github.com/python-jsonschema/check-jsonschema
42+
rev: 0.14.0
43+
hooks:
44+
- id: check-github-workflows

README.rst

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
11
======================================================
22
PyMAPDL Reader - Legacy Binary and Archive File Reader
33
======================================================
4-
.. image:: https://badge.fury.io/py/ansys-mapdl-reader.svg
5-
:target: https://badge.fury.io/py/ansys-mapdl-reader
4+
|pyansys| |pypi| |PyPIact| |GH-CI| |codecov| |MIT| |black|
65

7-
.. image:: https://github.com/pyansys/pymapdl-reader/actions/workflows/testing-and-deployment.yml/badge.svg
6+
.. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC
7+
:target: https://docs.pyansys.com/
8+
:alt: PyAnsys
9+
10+
.. |pypi| image:: https://img.shields.io/pypi/v/ansys-mapdl-reader.svg?logo=python&logoColor=white
11+
:target: https://pypi.org/project/ansys-mapdl-reader/
12+
13+
.. |PyPIact| image:: https://img.shields.io/pypi/dm/ansys-mapdl-reader.svg?label=PyPI%20downloads
14+
:target: https://pypi.org/project/ansys-mapdl-reader/
15+
16+
.. |codecov| image:: https://codecov.io/gh/pyansys/pymapdl-reader/branch/main/graph/badge.svg
17+
:target: https://codecov.io/gh/pyansys/pymapdl-reader
18+
19+
.. |GH-CI| image:: https://github.com/pyansys/pymapdl-reader/actions/workflows/testing-and-deployment.yml/badge.svg
820
:target: https://github.com/pyansys/pymapdl-reader/actions/workflows/testing-and-deployment.yml
921

22+
.. |MIT| image:: https://img.shields.io/badge/License-MIT-yellow.svg
23+
:target: https://opensource.org/licenses/MIT
24+
25+
.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat
26+
:target: https://github.com/psf/black
27+
:alt: black
28+
29+
1030
This is the legacy module for reading in binary and ASCII files
1131
generated from MAPDL.
1232

@@ -29,13 +49,13 @@ Please see the `PyMAPDL-Reader Documentation
2949

3050
.. note::
3151

32-
This module will likely change or be depreciated in the future.
52+
This module may be depreciated in the future.
3353

3454
You are encouraged to use the new Data Processing Framework (DPF)
35-
modules at `DPF-Core <https://github.com/pyansys/DPF-Core>`_ and
36-
`DPF-Post <https://github.com/pyansys/DPF-Post>`_ as they provide a
37-
modern interface to ANSYS result files using a client/server
38-
interface using the same software used within ANSYS Workbench, but
55+
modules at `PyDPF-Core <https://github.com/pyansys/pydpf-core>`_ and
56+
`PyDPF-Post <https://github.com/pyansys/pydpf-post>`_ as they provide a
57+
modern interface to Ansys result files using a client/server
58+
interface using the same software used within Ansys Workbench, but
3959
via a Python client.
4060

4161

@@ -48,6 +68,7 @@ Installation through pip::
4868
You can also visit `pymapdl-reader <https://github.com/pyansys/pymapdl-reader>`_
4969
to download the source or releases from GitHub.
5070

71+
5172
Python 3.10 Extra Instructions
5273
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5374

@@ -294,8 +315,6 @@ you will need to install your own C++ compiler. We recommend:
294315
a. Navigate to the project's top level (the same directory as this README)
295316
b. run ``pip install -e .``
296317
297-
To get the package up and running.
298-
299318
300319
License and Acknowledgments
301320
---------------------------

ansys/mapdl/reader/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1-
import appdirs
21
import os
32

3+
import appdirs
4+
45
# Per contract with Sphinx-Gallery, this method must be available at top level
56
from pyvista.utilities.sphinx_gallery import _get_sg_image_scraper
67

8+
from ansys.mapdl.reader import examples
79
from ansys.mapdl.reader._version import __version__
8-
from ansys.mapdl.reader.archive import (Archive, write_cmblock, write_nblock,
9-
save_as_archive)
10+
from ansys.mapdl.reader.archive import (
11+
Archive,
12+
save_as_archive,
13+
write_cmblock,
14+
write_nblock,
15+
)
1016
from ansys.mapdl.reader.cell_quality import quality
1117
from ansys.mapdl.reader.common import read_binary
1218
from ansys.mapdl.reader.misc import Report, _configure_pyvista
13-
from ansys.mapdl.reader import examples
19+
1420
from . import _archive
1521

1622
# Setup data directory
1723
try:
18-
USER_DATA_PATH = appdirs.user_data_dir('ansys_mapdl_reader')
24+
USER_DATA_PATH = appdirs.user_data_dir("ansys_mapdl_reader")
1925
if not os.path.exists(USER_DATA_PATH): # pragma: no cover
2026
os.makedirs(USER_DATA_PATH)
2127

22-
EXAMPLES_PATH = os.path.join(USER_DATA_PATH, 'examples')
28+
EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples")
2329
if not os.path.exists(EXAMPLES_PATH): # pragma: no cover
2430
os.makedirs(EXAMPLES_PATH)
2531

ansys/mapdl/reader/_mp_keys.py

Lines changed: 82 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,85 @@
2020
"""
2121

2222
# order is critical here
23-
mp_keys = ['EX', 'EY', 'EZ', 'NUXY', 'NUYZ', 'NUXZ', 'GXY', 'GYZ',
24-
'GXZ', 'ALPX', 'ALPY', 'ALPZ', 'DENS', 'MU', 'DAMP', 'KXX',
25-
'KYY', 'KZZ', 'RSVX', 'RSVY', 'RSVZ', 'C', 'HF', 'VISC',
26-
'EMIS', 'ENTH', 'LSST', 'PRXY', 'PRYZ', 'PRXZ', 'MURX',
27-
'MURY', 'MURZ', 'PERX', 'PERY', 'PERZ', 'MGXX', 'MGYY',
28-
'MGZZ', 'EGXX', 'EGYY', 'EGZZ', 'SBKX', 'SBKY', 'SBKZ',
29-
'SONC', 'SLIM', 'ELIM', 'USR1', 'USR2', 'USR3', 'USR4',
30-
'FLUI', 'ORTH', 'CABL', 'RIGI', 'HGLS', 'BVIS', 'QRAT',
31-
'REFT', 'CTEX', 'CTEY', 'CTEZ', 'THSX', 'THSY', 'THSZ',
32-
'DMPR', 'LSSM', 'BETD', 'ALPD', 'RH', 'DXX', 'DYY', 'DZZ',
33-
'BETX', 'BETY', 'BETZ', 'CSAT', 'CREF', 'CVH']
23+
mp_keys = [
24+
"EX",
25+
"EY",
26+
"EZ",
27+
"NUXY",
28+
"NUYZ",
29+
"NUXZ",
30+
"GXY",
31+
"GYZ",
32+
"GXZ",
33+
"ALPX",
34+
"ALPY",
35+
"ALPZ",
36+
"DENS",
37+
"MU",
38+
"DAMP",
39+
"KXX",
40+
"KYY",
41+
"KZZ",
42+
"RSVX",
43+
"RSVY",
44+
"RSVZ",
45+
"C",
46+
"HF",
47+
"VISC",
48+
"EMIS",
49+
"ENTH",
50+
"LSST",
51+
"PRXY",
52+
"PRYZ",
53+
"PRXZ",
54+
"MURX",
55+
"MURY",
56+
"MURZ",
57+
"PERX",
58+
"PERY",
59+
"PERZ",
60+
"MGXX",
61+
"MGYY",
62+
"MGZZ",
63+
"EGXX",
64+
"EGYY",
65+
"EGZZ",
66+
"SBKX",
67+
"SBKY",
68+
"SBKZ",
69+
"SONC",
70+
"SLIM",
71+
"ELIM",
72+
"USR1",
73+
"USR2",
74+
"USR3",
75+
"USR4",
76+
"FLUI",
77+
"ORTH",
78+
"CABL",
79+
"RIGI",
80+
"HGLS",
81+
"BVIS",
82+
"QRAT",
83+
"REFT",
84+
"CTEX",
85+
"CTEY",
86+
"CTEZ",
87+
"THSX",
88+
"THSY",
89+
"THSZ",
90+
"DMPR",
91+
"LSSM",
92+
"BETD",
93+
"ALPD",
94+
"RH",
95+
"DXX",
96+
"DYY",
97+
"DZZ",
98+
"BETX",
99+
"BETY",
100+
"BETZ",
101+
"CSAT",
102+
"CREF",
103+
"CVH",
104+
]

0 commit comments

Comments
 (0)