From b32b93d4d7cd4462fe44ebe51ce8214dce56dc67 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Sat, 21 Aug 2021 15:25:55 -0400 Subject: [PATCH 1/2] add examples to `DeepPot`'s docstring --- deepmd/infer/deep_pot.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/deepmd/infer/deep_pot.py b/deepmd/infer/deep_pot.py index 1e7ed52c39..3c5fb28f6e 100644 --- a/deepmd/infer/deep_pot.py +++ b/deepmd/infer/deep_pot.py @@ -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 From 9165b3f832a9c33bc01deb62599e57599673e734 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Sat, 21 Aug 2021 15:30:20 -0400 Subject: [PATCH 2/2] add an example to `calc_model_devi`'s docstring --- deepmd/infer/model_devi.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/deepmd/infer/model_devi.py b/deepmd/infer/model_devi.py index 2f8ea83335..74f33322a6 100644 --- a/deepmd/infer/model_devi.py +++ b/deepmd/infer/model_devi.py @@ -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