Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torchani
Commits
3132928c
Unverified
Commit
3132928c
authored
Oct 09, 2019
by
Gao, Xiang
Committed by
GitHub
Oct 09, 2019
Browse files
Add unit test for builtin models (#327)
* Add unit test for builtin models * flake8
parent
273c9fd6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
1 deletion
+53
-1
.github/workflows/unittest.yml
.github/workflows/unittest.yml
+5
-1
tests/test_jit_builtin_models.py
tests/test_jit_builtin_models.py
+48
-0
No files found.
.github/workflows/unittest.yml
View file @
3132928c
...
...
@@ -10,7 +10,11 @@ jobs:
fail-fast
:
false
matrix
:
python-version
:
[
3.6
,
3.7
]
test-filenames
:
[
test_aev.py
,
test_aev_benzene_md.py
,
test_aev_nist.py
,
test_aev_tripeptide_md.py
,
test_data_new.py
,
test_ignite.py
,
test_utils.py
,
test_ase.py
,
test_energies.py
,
test_neurochem.py
,
test_vibrational.py
,
test_ensemble.py
,
test_padding.py
,
test_data.py
,
test_forces.py
,
test_structure_optim.py
]
test-filenames
:
[
test_aev.py
,
test_aev_benzene_md.py
,
test_aev_nist.py
,
test_aev_tripeptide_md.py
,
test_data_new.py
,
test_ignite.py
,
test_utils.py
,
test_ase.py
,
test_energies.py
,
test_neurochem.py
,
test_vibrational.py
,
test_ensemble.py
,
test_padding.py
,
test_data.py
,
test_forces.py
,
test_structure_optim.py
,
test_jit_builtin_models.py
]
steps
:
-
uses
:
actions/checkout@v1
...
...
tests/test_jit_builtin_models.py
0 → 100644
View file @
3132928c
import
torch
import
torchani
import
unittest
import
os
path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
dspath
=
os
.
path
.
join
(
path
,
'../dataset/ani-1x/sample.h5'
)
batch_size
=
256
chunk_threshold
=
5
other_properties
=
{
'properties'
:
[
'energies'
],
'padding_values'
:
[
None
],
'padded_shapes'
:
[(
batch_size
,
)],
'dtypes'
:
[
torch
.
float64
],
}
class
TestBuiltinModelsJIT
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
ds
=
torchani
.
data
.
CachedDataset
(
dspath
,
batch_size
=
batch_size
,
device
=
'cpu'
,
chunk_threshold
=
chunk_threshold
,
other_properties
=
other_properties
,
subtract_self_energies
=
True
)
self
.
ani1ccx
=
torchani
.
models
.
ANI1ccx
()
def
_test_model
(
self
,
model
):
chunk
=
self
.
ds
[
0
][
0
][
0
]
_
,
e
=
model
(
chunk
)
_
,
e2
=
torch
.
jit
.
script
(
model
)(
chunk
)
self
.
assertTrue
(
torch
.
allclose
(
e
,
e2
))
def
_test_ensemble
(
self
,
ensemble
):
self
.
_test_model
(
ensemble
)
for
m
in
ensemble
:
self
.
_test_model
(
m
)
def
testANI1x
(
self
):
ani1x
=
torchani
.
models
.
ANI1x
()
self
.
_test_ensemble
(
ani1x
)
def
testANI1ccx
(
self
):
ani1ccx
=
torchani
.
models
.
ANI1ccx
()
self
.
_test_ensemble
(
ani1ccx
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment