Skip to content

Commit

Permalink
add examples to docstings (#1010)
Browse files Browse the repository at this point in the history
* add examples to `DeepPot`'s docstring

* add an example to `calc_model_devi`'s docstring
  • Loading branch information
njzjz authored Aug 22, 2021
1 parent 472d7c4 commit e9edec6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions deepmd/infer/deep_pot.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ class DeepPot(DeepEval):
default_tf_graph : bool
If uses the default tf graph, otherwise build a new tf graph for evaluation
Examples
--------
>>> 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])
>>> cell = np.diag(10 * np.ones(3)).reshape([1, -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.
Warnings
--------
For developers: `DeepTensor` initializer must be called at the end after
Expand Down
11 changes: 11 additions & 0 deletions deepmd/infer/model_devi.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ def calc_model_devi(coord,
model_devi : numpy.ndarray, `n_frames x 7`
Model deviation results. The first column is index of steps, the other 6 columns are
max_devi_v, min_devi_v, avg_devi_v, max_devi_f, min_devi_f, avg_devi_f.
Examples
--------
>>> from deepmd.infer import calc_model_devi
>>> from deepmd.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])
>>> cell = np.diag(10 * np.ones(3)).reshape([1, -1])
>>> atype = [1,0,1]
>>> graphs = [DP("graph.000.pb"), DP("graph.001.pb")]
>>> model_devi = calc_model_devi(coord, cell, atype, graphs)
'''
if nopbc:
box = None
Expand Down

0 comments on commit e9edec6

Please sign in to comment.