Skip to content

Commit 18508af

Browse files
authored
follow the numpydoc style guide (#420)
Add a pre-commit hook to run automatic tools to follow the Numpydoc style guide.
1 parent 4688fd6 commit 18508af

File tree

13 files changed

+70
-64
lines changed

13 files changed

+70
-64
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ repos:
2626
hooks:
2727
- id: isort
2828
files: \.py$
29+
# numpydoc
30+
- repo: https://github.com/Carreau/velin
31+
rev: 0.0.12
32+
hooks:
33+
- id: velin
34+
args: ["--write"]
2935
# Python inside docs
3036
- repo: https://github.com/asottile/blacken-docs
3137
rev: 1.13.0

dpdata/amber/mask.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ def pick_by_amber_mask(param, maskstr, coords=None):
1010
1111
Parameters
1212
----------
13-
param: str or parmed.Structure
14-
filename of Amber param file or parmed.Structure
15-
maskstr: str
16-
Amber masks
17-
coords: np.ndarray (optional)
18-
frame coordinates, shape: N*3
13+
param : str or parmed.Structure
14+
filename of Amber param file or parmed.Structure
15+
maskstr : str
16+
Amber masks
17+
coords : np.ndarray (optional)
18+
frame coordinates, shape: N*3
1919
"""
2020
parm = load_param_file(param)
2121
if coords is not None:

dpdata/amber/md.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ def read_amber_traj(
3535
Parameters
3636
----------
3737
parm7_file, nc_file, mdfrc_file, mden_file, mdout_file:
38-
filenames
39-
use_element_symbols: None or list or str
40-
If use_element_symbols is a list of atom indexes, these atoms will use element symbols
41-
instead of amber types. For example, a ligand will use C, H, O, N, and so on
42-
instead of h1, hc, o, os, and so on.
43-
IF use_element_symbols is str, it will be considered as Amber mask.
38+
filenames
39+
use_element_symbols : None or list or str
40+
If use_element_symbols is a list of atom indexes, these atoms will use element symbols
41+
instead of amber types. For example, a ligand will use C, H, O, N, and so on
42+
instead of h1, hc, o, os, and so on.
43+
IF use_element_symbols is str, it will be considered as Amber mask.
4444
"""
4545

4646
flag_atom_type = False

dpdata/driver.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class Driver(ABC):
2323
def register(key: str) -> Callable:
2424
"""Register a driver plugin. Used as decorators.
2525
26-
Parameter
27-
---------
28-
key: str
26+
Parameters
27+
----------
28+
key : str
2929
key of the plugin.
3030
3131
Returns
@@ -45,9 +45,9 @@ def register(key: str) -> Callable:
4545
def get_driver(key: str) -> "Driver":
4646
"""Get a driver plugin.
4747
48-
Parameter
49-
---------
50-
key: str
48+
Parameters
49+
----------
50+
key : str
5151
key of the plugin.
5252
5353
Returns
@@ -176,9 +176,9 @@ class Minimizer(ABC):
176176
def register(key: str) -> Callable:
177177
"""Register a minimizer plugin. Used as decorators.
178178
179-
Parameter
180-
---------
181-
key: str
179+
Parameters
180+
----------
181+
key : str
182182
key of the plugin.
183183
184184
Returns
@@ -198,9 +198,9 @@ def register(key: str) -> Callable:
198198
def get_minimizer(key: str) -> "Minimizer":
199199
"""Get a minimizer plugin.
200200
201-
Parameter
202-
---------
203-
key: str
201+
Parameters
202+
----------
203+
key : str
204204
key of the plugin.
205205
206206
Returns

dpdata/format.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def from_system(self, file_name, **kwargs):
5151
5252
Parameters
5353
----------
54-
file_name: str
54+
file_name : str
5555
file name
5656
5757
Returns
@@ -68,7 +68,7 @@ def to_system(self, data, *args, **kwargs):
6868
6969
Parameters
7070
----------
71-
data: dict
71+
data : dict
7272
system data
7373
"""
7474
raise NotImplementedError(
@@ -107,7 +107,7 @@ def from_multi_systems(self, directory, **kwargs):
107107
108108
Parameters
109109
----------
110-
directory: str
110+
directory : str
111111
directory of system
112112
113113
Returns

dpdata/md/rdf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ def rdf(sys, sel_type=[None, None], max_r=5, nbins=100):
99
----------
1010
sys : System or LabeledSystem
1111
The dpdata system
12-
sel_type: list
12+
sel_type : list
1313
List of size 2. The first element specifies the type of the first atom,
1414
while the second element specifies the type of the second atom.
1515
Both elements can be ints or list of ints.
1616
If the element is None, all types are specified.
1717
Examples are sel_type = [0, 0], sel_type = [0, [0, 1]] or sel_type = [0, None]
18-
max_r: float
18+
max_r : float
1919
Maximal range of rdf calculation
20-
nbins: int
20+
nbins : int
2121
Number of bins for rdf calculation
2222
2323
Returns

dpdata/plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def __init__(self):
1919
def register(self, key):
2020
"""Register a plugin.
2121
22-
Parameter
23-
---------
24-
key: str
22+
Parameters
23+
----------
24+
key : str
2525
Key of the plugin.
2626
"""
2727

dpdata/plugins/abacus.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ def to_system(self, data, file_name, frame_idx=0, **kwargs):
2020
The output file name
2121
frame_idx : int
2222
The index of the frame to dump
23-
pp_file: list of string, optional
23+
pp_file : list of string, optional
2424
List of pseudo potential files
25-
numerical_orbital: list of string, optional
25+
numerical_orbital : list of string, optional
2626
List of orbital files
27-
mass: list of float, optional
27+
mass : list of float, optional
2828
List of atomic masses
29-
numerical_descriptor: str, optional
29+
numerical_descriptor : str, optional
3030
numerical descriptor file
3131
"""
3232

dpdata/plugins/deepmd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ def to_system(self, data, file_name, set_size=5000, prec=np.float64, **kwargs):
5050
5151
Parameters
5252
----------
53-
data: dict
53+
data : dict
5454
System data
5555
file_name : str
5656
The output folder
5757
set_size : int
5858
The size of each set.
59-
prec: {numpy.float32, numpy.float64}
59+
prec : {numpy.float32, numpy.float64}
6060
The floating point precision of the compressed data
6161
"""
6262
dpdata.deepmd.comp.dump(file_name, data, set_size=set_size, comp_prec=prec)

dpdata/plugins/lammps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def to_system(self, data, file_name, frame_idx=0, **kwargs):
1818
1919
Parameters
2020
----------
21-
data: dict
21+
data : dict
2222
System data
2323
file_name : str
2424
The output file name

0 commit comments

Comments
 (0)