Skip to content

Commit

Permalink
enable docstring code format (#3267)
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
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] authored Feb 13, 2024
1 parent 6018e3c commit 398eb7a
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 20 deletions.
2 changes: 1 addition & 1 deletion deepmd/infer/deep_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def eval_typeebd(self) -> np.ndarray:
Get the output of type embedding network of `graph.pb`:
>>> from deepmd.infer import DeepPotential
>>> dp = DeepPotential('graph.pb')
>>> dp = DeepPotential("graph.pb")
>>> dp.eval_typeebd()
"""
return self.deep_eval.eval_typeebd()
Expand Down
6 changes: 3 additions & 3 deletions deepmd/infer/deep_pot.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class DeepPot(DeepEval):
--------
>>> from deepmd.infer import DeepPot
>>> import numpy as np
>>> dp = DeepPot('graph.pb')
>>> coord = np.array([[1,0,0], [0,0,1.5], [1,0,3]]).reshape([1, -1])
>>> dp = DeepPot("graph.pb")
>>> coord = np.array([[1, 0, 0], [0, 0, 1.5], [1, 0, 3]]).reshape([1, -1])
>>> cell = np.diag(10 * np.ones(3)).reshape([1, -1])
>>> atype = [1,0,1]
>>> atype = [1, 0, 1]
>>> e, f, v = dp.eval(coord, cell, atype)
where `e`, `f` and `v` are predicted energy, force and virial of the system, respectively.
Expand Down
4 changes: 2 additions & 2 deletions deepmd/infer/model_devi.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ def calc_model_devi(
>>> from deepmd.tf.infer import calc_model_devi
>>> from deepmd.tf.infer import DeepPot as DP
>>> import numpy as np
>>> coord = np.array([[1,0,0], [0,0,1.5], [1,0,3]]).reshape([1, -1])
>>> coord = np.array([[1, 0, 0], [0, 0, 1.5], [1, 0, 3]]).reshape([1, -1])
>>> cell = np.diag(10 * np.ones(3)).reshape([1, -1])
>>> atype = [1,0,1]
>>> atype = [1, 0, 1]
>>> graphs = [DP("graph.000.pb"), DP("graph.001.pb")]
>>> model_devi = calc_model_devi(coord, cell, atype, graphs)
"""
Expand Down
12 changes: 6 additions & 6 deletions deepmd/tf/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ def cast_precision(func: Callable) -> Callable:
Examples
--------
>>> class A:
... @property
... def precision(self):
... return tf.float32
... @property
... def precision(self):
... return tf.float32
...
... @cast_precision
... def f(x: tf.Tensor, y: tf.Tensor) -> tf.Tensor:
... return x ** 2 + y
... @cast_precision
... def f(x: tf.Tensor, y: tf.Tensor) -> tf.Tensor:
... return x**2 + y
"""

@wraps(func)
Expand Down
2 changes: 1 addition & 1 deletion deepmd/tf/descriptor/descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Descriptor(PluginVariant):
Examples
--------
>>> descript = Descriptor(type="se_e2_a", rcut=6., rcut_smth=0.5, sel=[50])
>>> descript = Descriptor(type="se_e2_a", rcut=6.0, rcut_smth=0.5, sel=[50])
>>> type(descript)
<class 'deepmd.tf.descriptor.se_a.DescrptSeA'>
Expand Down
25 changes: 24 additions & 1 deletion deepmd/tf/entrypoints/neighbor_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,30 @@ def neighbor_stat(
Examples
--------
>>> neighbor_stat(system='.', rcut=6., type_map=["C", "H", "O", "N", "P", "S", "Mg", "Na", "HW", "OW", "mNa", "mCl", "mC", "mH", "mMg", "mN", "mO", "mP"])
>>> neighbor_stat(
... system=".",
... rcut=6.0,
... type_map=[
... "C",
... "H",
... "O",
... "N",
... "P",
... "S",
... "Mg",
... "Na",
... "HW",
... "OW",
... "mNa",
... "mCl",
... "mC",
... "mH",
... "mMg",
... "mN",
... "mO",
... "mP",
... ],
... )
min_nbor_dist: 0.6599510670195264
max_nbor_size: [23, 26, 19, 16, 2, 2, 1, 1, 72, 37, 5, 0, 31, 29, 1, 21, 20, 5]
"""
Expand Down
4 changes: 2 additions & 2 deletions deepmd/tf/infer/deep_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def eval_typeebd(self) -> np.ndarray:
Get the output of type embedding network of `graph.pb`:
>>> from deepmd.tf.infer import DeepPotential
>>> dp = DeepPotential('graph.pb')
>>> dp = DeepPotential("graph.pb")
>>> dp.eval_typeebd()
"""
t_typeebd = self._get_tensor("t_typeebd:0")
Expand Down Expand Up @@ -1429,7 +1429,7 @@ def eval_typeebd(self) -> np.ndarray:
Get the output of type embedding network of `graph.pb`:
>>> from deepmd.tf.infer import DeepPotential
>>> dp = DeepPotential('graph.pb')
>>> dp = DeepPotential("graph.pb")
>>> dp.eval_typeebd()
"""
t_typeebd = self._get_tensor("t_typeebd:0")
Expand Down
2 changes: 0 additions & 2 deletions deepmd/tf/utils/parallel_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ class ParallelOp:
>>> def builder():
... x = tf.placeholder(tf.int32, [1])
... return {"x": x}, (x + 1)
...
>>> p = ParallelOp(builder, nthreads=4)
>>> def feed():
... for ii in range(10):
... yield {"x": [ii]}
...
>>> print(*p.generate(tf.Session(), feed()))
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
"""
Expand Down
2 changes: 1 addition & 1 deletion deepmd/utils/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Plugin:
>>> @plugin.register("xx")
def xxx():
pass
>>> print(plugin.plugins['xx'])
>>> print(plugin.plugins["xx"])
"""

def __init__(self):
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ ignore = "D413, D416, D203, D107, D213"
profile = "black"
force_grid_wrap = 1

[tool.ruff.format]
docstring-code-format = true

[tool.ruff.lint]
select = [
"E", # errors
Expand Down
2 changes: 1 addition & 1 deletion source/install/build_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def set_directory(path: Path):
Examples
--------
>>> with set_directory("some_path"):
... do_something()
... do_something()
"""
cwd = Path().absolute()
path.mkdir(exist_ok=True, parents=True)
Expand Down

0 comments on commit 398eb7a

Please sign in to comment.