Skip to content

Commit

Permalink
fix the docstring styles (#128)
Browse files Browse the repository at this point in the history
Follow the Numpydoc style guide.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
njzjz and pre-commit-ci[bot] committed Feb 5, 2023
1 parent b35becb commit 89f7c95
Show file tree
Hide file tree
Showing 24 changed files with 145 additions and 140 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ repos:
hooks:
- id: isort
files: \.py$
# numpydoc
- repo: https://github.com/Carreau/velin
rev: 0.0.12
hooks:
- id: velin
args: ["--write"]
46 changes: 23 additions & 23 deletions dpgen2/conf/alloy_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ def generate(
Parameters
----------
type_map: List[str]
The type map.
type_map : List[str]
The type map.
Returns
-------
confs: dpdata.MultiSystems
The returned configurations in `dpdata.MultiSystems` format
The returned configurations in `dpdata.MultiSystems` format
"""
ms = dpdata.MultiSystems(type_map=type_map)
Expand Down Expand Up @@ -187,25 +187,25 @@ def generate_file_content(
Parameters
----------
numb_confs int
Number of configurations to generate
Number of configurations to generate
concentration List[List[float]] or List[float] or None
If `List[float]`, the concentrations of each element. The length of
the list should be the same as the `type_map`.
If `List[List[float]]`, a list of concentrations (`List[float]`) is
randomly picked from the List.
If `None`, the elements are assumed to be of equal concentration.
If `List[float]`, the concentrations of each element. The length of
the list should be the same as the `type_map`.
If `List[List[float]]`, a list of concentrations (`List[float]`) is
randomly picked from the List.
If `None`, the elements are assumed to be of equal concentration.
cell_pert_frac float
fraction of cell perturbation
fraction of cell perturbation
atom_pert_dist float
the atom perturbation distance (unit angstrom).
the atom perturbation distance (unit angstrom).
fmt str
the format of the returned conf strings.
Should be one of the formats supported by `dpdata`
the format of the returned conf strings.
Should be one of the formats supported by `dpdata`
Returns
-------
conf_list List[str]
A list of file content of configurations.
A list of file content of configurations.
"""
ret = []
for ii in range(numb_confs):
Expand All @@ -227,22 +227,22 @@ def generate_systems(
Parameters
----------
numb_confs int
Number of configurations to generate
Number of configurations to generate
concentration List[List[float]] or List[float] or None
If `List[float]`, the concentrations of each element. The length of
the list should be the same as the `type_map`.
If `List[List[float]]`, a list of concentrations (`List[float]`) is
randomly picked from the List.
If `None`, the elements are assumed to be of equal concentration.
If `List[float]`, the concentrations of each element. The length of
the list should be the same as the `type_map`.
If `List[List[float]]`, a list of concentrations (`List[float]`) is
randomly picked from the List.
If `None`, the elements are assumed to be of equal concentration.
cell_pert_frac float
fraction of cell perturbation
fraction of cell perturbation
atom_pert_dist float
the atom perturbation distance (unit angstrom).
the atom perturbation distance (unit angstrom).
Returns
-------
conf_list List[dpdata.System]
A list of generated confs in `dpdata.System`.
A list of generated confs in `dpdata.System`.
"""
ret = [
self._generate_one_sys(concentration, cell_pert_frac, atom_pert_dist)
Expand Down
16 changes: 8 additions & 8 deletions dpgen2/conf/conf_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def generate(
Parameters
----------
type_map: List[str]
The type map.
type_map : List[str]
The type map.
Returns
-------
confs: dpdata.MultiSystems
The returned configurations in `dpdata.MultiSystems` format
The returned configurations in `dpdata.MultiSystems` format
"""
pass
Expand All @@ -45,13 +45,13 @@ def get_file_content(
Parameters
----------
type_map: List[str]
The type map.
type_map : List[str]
The type map.
Returns
-------
conf_list: List[str]
A list of file content of configurations.
A list of file content of configurations.
"""
ret = []
Expand Down Expand Up @@ -80,9 +80,9 @@ def normalize_config(
Parameters
----------
data: Dict
data : Dict
The input dict of arguments.
strict: bool
strict : bool
Strictly check the arguments.
Returns
Expand Down
2 changes: 1 addition & 1 deletion dpgen2/entrypoint/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def parse_args(args: Optional[List[str]] = None):
Parameters
----------
args: List[str]
args : List[str]
list of command line arguments, main purpose is testing default option None
takes arguments from sys.argv
"""
Expand Down
34 changes: 17 additions & 17 deletions dpgen2/exploration/render/traj_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ def get_model_devi(
Parameters
----------
files: List[Path]
The paths to the model deviation recording files
files : List[Path]
The paths to the model deviation recording files
Returns
-------
model_devis: Tuple[List[np.array], Union[List[np.array],None]]
A tuple. model_devis[0] is the force model deviations,
model_devis[1] is the virial model deviations.
The model_devis[1] can be None.
If not None, model_devis[i] is List[np.array], where np.array is a
one-dimensional array.
The first dimension of model_devis[i] is the trajectory
(same size as len(files)), while the second dimension is the frame.
A tuple. model_devis[0] is the force model deviations,
model_devis[1] is the virial model deviations.
The model_devis[1] can be None.
If not None, model_devis[i] is List[np.array], where np.array is a
one-dimensional array.
The first dimension of model_devis[i] is the trajectory
(same size as len(files)), while the second dimension is the frame.
"""
pass

Expand All @@ -60,17 +60,17 @@ def get_confs(
Parameters
----------
traj: List[Path]
Trajectory files
id_selected: List[List[int]]
The selected frames. id_selected[ii][jj] is the jj-th selected frame
from the ii-th trajectory. id_selected[ii] may be an empty list.
type_map: List[str]
The type map.
traj : List[Path]
Trajectory files
id_selected : List[List[int]]
The selected frames. id_selected[ii][jj] is the jj-th selected frame
from the ii-th trajectory. id_selected[ii] may be an empty list.
type_map : List[str]
The type map.
Returns
-------
ms: dpdata.MultiSystems
The configurations in dpdata.MultiSystems format
The configurations in dpdata.MultiSystems format
"""
pass
24 changes: 12 additions & 12 deletions dpgen2/exploration/report/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def record(
Parameters
----------
mdf : List[np.ndarray]
The force model deviations. mdf[ii][jj] is the force model deviation
of the jj-th frame of the ii-th trajectory.
The force model deviations. mdf[ii][jj] is the force model deviation
of the jj-th frame of the ii-th trajectory.
mdv : Optional[List[np.ndarray]]
The virial model deviations. mdv[ii][jj] is the virial model deviation
of the jj-th frame of the ii-th trajectory.
The virial model deviations. mdv[ii][jj] is the virial model deviation
of the jj-th frame of the ii-th trajectory.
"""
pass

Expand All @@ -45,13 +45,13 @@ def converged(
Parameters
----------
reports List[ExplorationReportTrustLevels]
Historical reports
reports
Historical reports
Returns
-------
converged bool
If the exploration is converged.
If the exploration is converged.
"""
pass

Expand All @@ -68,15 +68,15 @@ def get_candidate_ids(
Parameters
----------
max_nframes int
The maximal number of frames of candidates.
max_nframes
The maximal number of frames of candidates.
Returns
-------
idx: List[List[int]]
The frame indices of candidate configurations.
idx[ii][jj] is the frame index of the jj-th candidate of the
ii-th trajectory.
The frame indices of candidate configurations.
idx[ii][jj] is the frame index of the jj-th candidate of the
ii-th trajectory.
"""
pass

Expand Down
6 changes: 3 additions & 3 deletions dpgen2/exploration/report/report_adaptive_lower.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,13 @@ def _get_candidates(
Parameters
----------
max_nframes int
The maximal number of frames of candidates.
max_nframes
The maximal number of frames of candidates.
Returns
-------
cand_frames List[Tuple[int,int]]
Candidate frames. A list of tuples: [(traj_idx, frame_idx), ...]
Candidate frames. A list of tuples: [(traj_idx, frame_idx), ...]
"""
self.candi_picked = [(ii[0], ii[1]) for ii in self.candi]
if max_nframes is not None and max_nframes < len(self.candi_picked):
Expand Down
12 changes: 6 additions & 6 deletions dpgen2/exploration/report/report_trust_levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ def converged(
Parameters
----------
reports List[ExplorationReportTrustLevels]
Historical reports
reports
Historical reports
Returns
-------
converged bool
If the exploration is converged.
If the exploration is converged.
"""
return self.accurate_ratio() >= self.conv_accuracy

Expand Down Expand Up @@ -246,13 +246,13 @@ def _get_candidates(
Parameters
----------
max_nframes int
The maximal number of frames of candidates.
max_nframes
The maximal number of frames of candidates.
Returns
-------
cand_frames List[Tuple[int,int]]
Candidate frames. A list of tuples: [(traj_idx, frame_idx), ...]
Candidate frames. A list of tuples: [(traj_idx, frame_idx), ...]
"""
self.traj_cand_picked = []
for tidx, tt in enumerate(self.traj_cand):
Expand Down
10 changes: 5 additions & 5 deletions dpgen2/exploration/scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def add_stage_scheduler(
Parameters
----------
stage_scheduler: StageScheduler
stage_scheduler : StageScheduler
The added stage scheduler
"""
Expand Down Expand Up @@ -119,7 +119,7 @@ def plan_next_iteration(
----------
report : ExplorationReport
The exploration report of this iteration.
confs: List[Path]
trajs : List[Path]
A list of configurations generated during the exploration. May be used to generate new configurations for the next iteration.
Returns
Expand Down Expand Up @@ -197,11 +197,11 @@ def get_convergence_ratio(self):
Returns
-------
accu np.ndarray
The accurate ratio. length of array the same as # iterations.
The accurate ratio. length of array the same as # iterations.
cand np.ndarray
The candidate ratio. length of array the same as # iterations.
The candidate ratio. length of array the same as # iterations.
fail np.ndarray
The failed ration. length of array the same as # iterations.
The failed ration. length of array the same as # iterations.
"""
stages = self.stage_schedulers
stag_idx, idx_in_stag, iter_idx = self.get_stage_of_iterations()
Expand Down
12 changes: 6 additions & 6 deletions dpgen2/exploration/scheduler/stage_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def converged(self) -> bool:
Returns
-------
converged bool
the convergence
the convergence
"""
pass

Expand All @@ -47,7 +47,7 @@ def complete(self) -> bool:
Returns
-------
converged bool
if the stage is complete
if the stage is complete
"""
pass

Expand All @@ -67,7 +67,7 @@ def next_iteration(self) -> int:
Returns
-------
index int
the index of the next iteration
the index of the next iteration
"""
pass

Expand All @@ -79,7 +79,7 @@ def get_reports(self) -> List[ExplorationReport]:
Returns
-------
reports List[ExplorationReport]
the reports
the reports
"""
pass

Expand All @@ -96,11 +96,11 @@ def plan_next_iteration(
Parameters
----------
hist_reports: List[ExplorationReport]
hist_reports : List[ExplorationReport]
The historical exploration report of the stage. If this is the first iteration of the stage, this list is empty.
report : ExplorationReport
The exploration report of this iteration.
confs: List[Path]
confs : List[Path]
A list of configurations generated during the exploration. May be used to generate new configurations for the next iteration.
Returns
Expand Down

0 comments on commit 89f7c95

Please sign in to comment.