Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding numpydoc hook #2381

Merged
merged 12 commits into from
Oct 24, 2023
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ repos:
hooks:
- id: isort

- repo: https://github.com/numpy/numpydoc
rev: v1.6.0
hooks:
- id: numpydoc-validation
germa89 marked this conversation as resolved.
Show resolved Hide resolved
exclude: |
(?x)(
tests/|
examples|
doc/source/|
src/ansys/mapdl/core/_commands|
src/ansys/mapdl/core/commands
)

- repo: https://github.com/psf/black
rev: 23.9.1 # IF VERSION CHANGES --> MODIFY "blacken-docs" MANUALLY AS WELL!!
hooks:
Expand Down
69 changes: 68 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,71 @@ show_missing = true
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/*'
ignore-words = "doc/styles/Vocab/ANSYS/accept.txt"
quiet-level = 3
ignore-regex=".*codespell-ignore$|NORML|POIN"
ignore-regex=".*codespell-ignore$|NORML|POIN"

[tool.numpydoc_validation]
checks = [
#"all", # report on all checks, except the below
# "GL01", # "Docstring text (summary) should start in the line immediately "
# "after the opening quotes (not in the same line, or leaving a "
# "blank line in between)",
# "GL02", # "Closing quotes should be placed in the line after the last text "
# "in the docstring (do not close the quotes in the same line as "
# "the text, or leave a blank line between the last text and the "
# "quotes)",
# "GL03", # "Double line break found; please use only one blank line to "
# "separate sections or paragraphs, and do not leave blank lines "
# "at the end of docstrings",
"GL05", # 'Tabs found at the start of line "{line_with_tabs}", please use '
# "whitespace only",
# "GL06", # 'Found unknown section "{section}". Allowed sections are: '
# "{allowed_sections}",
"GL07", # "Sections are in the wrong order. Correct order is: {correct_sections}",
# "GL08", # "The object does not have a docstring",
# "GL09", # "Deprecation warning should precede extended summary",
"GL10", # "reST directives {directives} must be followed by two colons",
# "SS01", # "No summary found (a short summary in a single line should be "
# "present at the beginning of the docstring)",
"SS02", # "Summary does not start with a capital letter",
# "SS03", # "Summary does not end with a period",
"SS04", # "Summary contains heading whitespaces",
# "SS05", # "Summary must start with infinitive verb, not third person "
# '(e.g. use "Generate" instead of "Generates")',
# "SS06", # "Summary should fit in a single line",
# "ES01", # "No extended summary found",
# "PR01", # "Parameters {missing_params} not documented",
# "PR02", # "Unknown parameters {unknown_params}",
"PR03", # "Wrong parameters order. Actual: {actual_params}. "
# "Documented: {documented_params}",
# "PR04", # 'Parameter "{param_name}" has no type',
"PR05", # 'Parameter "{param_name}" type should not finish with "."',
"PR06", # 'Parameter "{param_name}" type should use "{right_type}" instead '
# 'of "{wrong_type}"',
"PR07", # 'Parameter "{param_name}" has no description',
# "PR08", # 'Parameter "{param_name}" description should start with a '
# "capital letter",
# "PR09", # 'Parameter "{param_name}" description should finish with "."',
# "PR10", # 'Parameter "{param_name}" requires a space before the colon '
# "separating the parameter name and type",
# "RT01", # "No Returns section found",
# "RT02", # "The first line of the Returns section should contain only the "
# "type, unless multiple values are being returned",
# "RT03", # "Return value has no description",
# "RT04", # "Return value description should start with a capital letter",
# "RT05", # 'Return value description should finish with "."',
"YD01", # "No Yields section found",
# "SA01", # "See Also section not found",
"SA02", # "Missing period at end of description for See Also "
# '"{reference_name}" reference',
"SA03", # "Description should be capitalized for See Also "
# '"{reference_name}" reference',
"SA04", # 'Missing description for See Also "{reference_name}" reference',
# "EX01", # "No examples section found",
]


override_SS05 = [ # override SS05 to allow docstrings starting with these words
# '^Process ',
# '^Assess ',
# '^Access ',
]
2 changes: 1 addition & 1 deletion src/ansys/mapdl/core/_commands/preproc/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ def eplot(self, **kwargs):
APDL Command: EPLOT
Notes
------
-----
Produces an element display of the selected elements. In full
graphics, only those elements faces with all of their corresponding
nodes selected are plotted. In PowerGraphics, all element faces of the selected
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/mapdl/core/common_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def check_vget_input(entity: str, item: str, itnum: str) -> str:
Returns
-------
command : str
str
MAPDL formatted vget command after the "VGET, " in the format of:
"ENTITY, , ITEM, ITNUM"
"""
Expand Down Expand Up @@ -158,7 +158,7 @@ def parse_chunks(chunks, dtype=None):
Returns
-------
array : np.ndarray
np.ndarray
Deserialized numpy array.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/mapdl/core/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""pymapdl specific errors"""
"""PyMAPDL specific errors"""

from functools import wraps
import signal
Expand Down
6 changes: 3 additions & 3 deletions src/ansys/mapdl/core/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,15 +1077,15 @@ def launch_mapdl(
``log_apdl='pymapdl_log.txt'``). By default this is disabled.

remove_temp_files : bool, optional
.. deprecated:: 0.64.0
Use argument ``remove_temp_dir_on_exit`` instead.

When ``run_location`` is ``None``, this launcher creates a new MAPDL
working directory within the user temporary directory, obtainable with
``tempfile.gettempdir()``. When this parameter is
``True``, this directory will be deleted when MAPDL is exited. Default
``False``.

.. deprecated:: 0.64.0
Use argument ``remove_temp_dir_on_exit`` instead.

remove_temp_dir_on_exit : bool, optional
When ``run_location`` is ``None``, this launcher creates a new MAPDL
working directory within the user temporary directory, obtainable with
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/mapdl/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
outputs and it is used to track the different MAPDL instances.
Usage
-----
How to use
==========
Global logger
~~~~~~~~~~~~~
Expand Down
6 changes: 4 additions & 2 deletions src/ansys/mapdl/core/mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3002,6 +3002,8 @@ def run_multiline(self, commands) -> str:
This function is being deprecated. Please use `input_strings`
instead.

Allows to run multiple mapdl commands in different lines in one go.

Parameters
----------
commands : str
Expand Down Expand Up @@ -3642,7 +3644,7 @@ def directory(self, path: Union[str, pathlib.Path]) -> None:

@property
def _lockfile(self):
"""lockfile path"""
"""Lockfile path"""
path = self.directory
if path is not None:
return os.path.join(path, self.jobname + ".lock").replace("\\", "/")
Expand Down Expand Up @@ -3885,7 +3887,7 @@ def _screenshot_path(self):
return filenames[-1]

def _set_log_level(self, level):
"""alias for set_log_level"""
"""Alias for set_log_level"""
self.set_log_level(level)

def list(self, filename, ext=""):
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/mapdl/core/mapdl_corba.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def _run(self, command, **kwargs):
return response

def _close_output(self):
"""closes the output file"""
"""Closes the output file"""
self._output = ""
if self._outfile:
self._outfile.close()
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""gRPC specific class and methods for the MAPDL gRPC client """
"""A gRPC specific class and methods for the MAPDL gRPC client """

import fnmatch
from functools import wraps
Expand Down Expand Up @@ -2473,7 +2473,7 @@ def _get_array(
kloop="",
**kwargs,
):
"""gRPC VGET request.
"""Do a gRPC VGET request.
Send a vget request, receive a bytes stream, and return it as
a numpy array.
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/mapdl/core/mesh_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def _load_nodes(self, chunk_size=DEFAULT_CHUNKSIZE):
Returns
-------
nodes : np.ndarray
np.ndarray
Numpy array of nodes
"""
if self._chunk_size:
Expand Down Expand Up @@ -655,7 +655,7 @@ def _load_element_types(self, chunk_size=DEFAULT_CHUNKSIZE):
Parameters
----------
chunk_size : int
int
Size of the chunks to request from the server.
"""
request = anskernel.StreamRequest(chunk_size=chunk_size)
Expand Down
6 changes: 3 additions & 3 deletions src/ansys/mapdl/core/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,12 @@ def _set_parameter_array(self, name, arr):
Parameters
----------
arr : np.ndarray or List
Array to send to MAPDL. Maximum of 3 dimensions.
name : str
Name of the array to write to within MAPDL.
arr : np.ndarray or List
Array to send to MAPDL. Maximum of 3 dimensions.
Examples
--------
Load a 1D numpy array into MAPDL
Expand Down
14 changes: 7 additions & 7 deletions src/ansys/mapdl/core/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ def _general_plotter(
``off_screen`` are evaluated to ``False`` and ``True``
respectively.
style : string, optional
style : str, optional
Visualization style of the mesh. One of the following:
``style='surface'``, ``style='wireframe'``,
``style='points'``. Defaults to ``'surface'``. Note that
``'wireframe'`` only shows a wireframe of the outer geometry.
color : string or 3 item list, optional
color : str, list[int, int, int], optional
Use to make the entire mesh have a single solid color. Either
a string, RGB list, or hex color string. For example:
``color='white'``, ``color='w'``, ``color=[1, 1, 1]``, or
Expand All @@ -241,9 +241,9 @@ def _general_plotter(
Shows the edges of a mesh. Does not apply to a wireframe
representation.
edge_color : string or 3 item list, optional, defaults to black
edge_color : str, list[int, int, int], optional
The solid color to give the edges when ``show_edges=True``.
Either a string, RGB list, or hex color string.
Either a string, RGB list, or hex color string. Defaults to black.
point_size : float, optional
Point size of any nodes in the dataset plotted. Also applicable
Expand Down Expand Up @@ -594,13 +594,13 @@ def general_plotter(
savefig : str, optional
Saves screenshot to a file path.
style : string, optional
style : str, optional
Visualization style of the mesh. One of the following:
``style='surface'``, ``style='wireframe'``,
``style='points'``. Defaults to ``'surface'``. Note that
``'wireframe'`` only shows a wireframe of the outer geometry.
color : string or 3 item list, optional
color : str, list[int, int, int], optional
Use to make the entire mesh have a single solid color. Either
a string, RGB list, or hex color string. For example:
``color='white'``, ``color='w'``, ``color=[1, 1, 1]``, or
Expand All @@ -611,7 +611,7 @@ def general_plotter(
Shows the edges of a mesh. Does not apply to a wireframe
representation.
edge_color : string or 3 item list, optional,
edge_color : str, list[int, int, int], optional
The solid color to give the edges when ``show_edges=True``.
Either a string, RGB list, or hex color string.
Defaults to black.
Expand Down
5 changes: 3 additions & 2 deletions src/ansys/mapdl/core/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ def _mapdl(self):

@property
def _log(self):
"""alias for mapdl log"""
"""Alias for mapdl log"""
return self._mapdl._log

def _set_log_level(self, level):
"""alias for mapdl._set_log_level"""
"""Alias for mapdl._set_log_level"""
return self._mapdl._set_log_level(level)

@supress_logging
Expand Down Expand Up @@ -1346,6 +1346,7 @@ def plot_element_stress(
**kwargs : dict, optional
Keyword arguments passed to :func:`general_plotter
<ansys.mapdl.core.plotting.general_plotter>`
Returns
-------
pyvista.plotting.renderer.CameraPosition
Expand Down
3 changes: 1 addition & 2 deletions src/ansys/mapdl/core/xpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,7 @@ def save(self):
return response

def extract(self, recordname, sets="ALL", asarray=False):
"""
Import a Matrix/Vector from a MAPDL result file.
"""Import a Matrix/Vector from a MAPDL result file.
At the moment, this only supports reading the displacement vectors from
a result file.
Expand Down