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
2007d181
"vscode:/vscode.git/clone" did not exist on "218099b35d4c1d3ab5f500075e7d5b66f0faa13f"
Unverified
Commit
2007d181
authored
Mar 12, 2021
by
Jinze Xue
Committed by
GitHub
Mar 12, 2021
Browse files
remove test warning (#584)
parent
1d64bbae
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
40 additions
and
25 deletions
+40
-25
tests/common_aev_test.py
tests/common_aev_test.py
+2
-1
tests/test_aev.py
tests/test_aev.py
+6
-5
tests/test_al.py
tests/test_al.py
+2
-1
tests/test_ase.py
tests/test_ase.py
+2
-1
tests/test_data.py
tests/test_data.py
+2
-1
tests/test_energies.py
tests/test_energies.py
+3
-2
tests/test_ensemble.py
tests/test_ensemble.py
+2
-1
tests/test_forces.py
tests/test_forces.py
+2
-1
tests/test_grad.py
tests/test_grad.py
+2
-1
tests/test_jit_builtin_models.py
tests/test_jit_builtin_models.py
+2
-1
tests/test_neurochem.py
tests/test_neurochem.py
+2
-1
tests/test_padding.py
tests/test_padding.py
+3
-2
tests/test_periodic_table_indexing.py
tests/test_periodic_table_indexing.py
+3
-2
tests/test_structure_optim.py
tests/test_structure_optim.py
+2
-1
tests/test_utils.py
tests/test_utils.py
+2
-1
tests/test_vibrational.py
tests/test_vibrational.py
+2
-1
torchani/__init__.py
torchani/__init__.py
+1
-2
No files found.
tests/common_aev_test.py
View file @
2007d181
import
torch
import
torchani
import
os
from
torchani.testing
import
TestCase
class
_TestAEVBase
(
torchani
.
testing
.
TestCase
):
class
_TestAEVBase
(
TestCase
):
def
setUp
(
self
):
path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
...
...
tests/test_aev.py
View file @
2007d181
...
...
@@ -9,6 +9,7 @@ import ase.io
import
math
import
traceback
from
common_aev_test
import
_TestAEVBase
from
torchani.testing
import
TestCase
path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
...
...
@@ -16,7 +17,7 @@ const_file = os.path.join(path, '../torchani/resources/ani-1x_8x/rHCNO-5.2R_16-3
N
=
97
class
TestAEVConstructor
(
torchani
.
testing
.
TestCase
):
class
TestAEVConstructor
(
TestCase
):
# Test that checks that the friendly constructor
# reproduces the values from ANI1x with the correct parameters
def
testCoverLinearly
(
self
):
...
...
@@ -38,7 +39,7 @@ class TestAEVConstructor(torchani.testing.TestCase):
self
.
assertEqual
(
c
,
ca
)
class
TestIsolated
(
torchani
.
testing
.
TestCase
):
class
TestIsolated
(
TestCase
):
# Tests that there is no error when atoms are separated
# a distance greater than the cutoff radius from all other atoms
# this can throw an IndexError for large distances or lone atoms
...
...
@@ -157,7 +158,7 @@ class TestAEVJIT(TestAEV):
self
.
aev_computer
=
torch
.
jit
.
script
(
self
.
aev_computer
)
class
TestPBCSeeEachOther
(
torchani
.
testing
.
TestCase
):
class
TestPBCSeeEachOther
(
TestCase
):
def
setUp
(
self
):
consts
=
torchani
.
neurochem
.
Constants
(
const_file
)
self
.
aev_computer
=
torchani
.
AEVComputer
(
**
consts
).
to
(
torch
.
double
)
...
...
@@ -261,7 +262,7 @@ class TestPBCSeeEachOther(torchani.testing.TestCase):
self
.
assertEqual
(
atom_index2
.
tolist
(),
[
1
])
class
TestAEVOnBoundary
(
torchani
.
testing
.
TestCase
):
class
TestAEVOnBoundary
(
TestCase
):
def
setUp
(
self
):
self
.
eps
=
1e-9
...
...
@@ -307,7 +308,7 @@ class TestAEVOnBoundary(torchani.testing.TestCase):
self
.
assertEqual
(
aev
,
self
.
aev
)
class
TestAEVOnBenzenePBC
(
torchani
.
testing
.
TestCase
):
class
TestAEVOnBenzenePBC
(
TestCase
):
def
setUp
(
self
):
consts
=
torchani
.
neurochem
.
Constants
(
const_file
)
...
...
tests/test_al.py
View file @
2007d181
...
...
@@ -2,9 +2,10 @@ import torch
import
torchani
import
math
import
unittest
from
torchani.testing
import
TestCase
class
TestALAtomic
(
torchani
.
testing
.
TestCase
):
class
TestALAtomic
(
TestCase
):
def
setUp
(
self
):
self
.
device
=
torch
.
device
(
'cuda'
if
torch
.
cuda
.
is_available
()
else
'cpu'
)
...
...
tests/test_ase.py
View file @
2007d181
...
...
@@ -4,6 +4,7 @@ from ase.md.nptberendsen import NPTBerendsen
from
ase
import
units
from
ase.io
import
read
from
ase.calculators.test
import
numeric_force
from
torchani.testing
import
TestCase
import
numpy
as
np
import
torch
import
torchani
...
...
@@ -21,7 +22,7 @@ def get_numeric_force(atoms, eps):
return
fn
class
TestASE
(
torchani
.
testing
.
TestCase
):
class
TestASE
(
TestCase
):
def
setUp
(
self
):
self
.
model
=
torchani
.
models
.
ANI1x
(
model_index
=
0
).
double
()
...
...
tests/test_data.py
View file @
2007d181
...
...
@@ -2,6 +2,7 @@ import os
import
torch
import
torchani
import
unittest
from
torchani.testing
import
TestCase
path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
dataset_path
=
os
.
path
.
join
(
path
,
'../dataset/ani-1x/sample.h5'
)
...
...
@@ -9,7 +10,7 @@ batch_size = 256
ani1x_sae_dict
=
{
'H'
:
-
0.60095298
,
'C'
:
-
38.08316124
,
'N'
:
-
54.7077577
,
'O'
:
-
75.19446356
}
class
TestData
(
torchani
.
testing
.
TestCase
):
class
TestData
(
TestCase
):
def
testTensorShape
(
self
):
ds
=
torchani
.
data
.
load
(
dataset_path
).
subtract_self_energies
(
ani1x_sae_dict
).
species_to_indices
().
shuffle
().
collate
(
batch_size
).
cache
()
...
...
tests/test_energies.py
View file @
2007d181
...
...
@@ -3,13 +3,14 @@ import torchani
import
unittest
import
os
import
pickle
from
torchani.testing
import
TestCase
path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
N
=
97
class
TestCorrectInput
(
torchani
.
testing
.
TestCase
):
class
TestCorrectInput
(
TestCase
):
def
setUp
(
self
):
self
.
model
=
torchani
.
models
.
ANI1x
(
model_index
=
0
,
periodic_table_index
=
False
)
...
...
@@ -32,7 +33,7 @@ class TestCorrectInput(torchani.testing.TestCase):
self
.
assertRaises
(
AssertionError
,
self
.
model
,
(
torch
.
tensor
([
0
,
1
,
2
,
3
]),
torch
.
zeros
((
4
,
3
))))
class
TestEnergies
(
torchani
.
testing
.
TestCase
):
class
TestEnergies
(
TestCase
):
# tests the predicions for a torchani.nn.Sequential(AEVComputer(),
# ANIModel(), EnergyShifter()) against precomputed values
...
...
tests/test_ensemble.py
View file @
2007d181
...
...
@@ -3,12 +3,13 @@ import pickle
import
os
import
torch
import
torchani
from
torchani.testing
import
TestCase
path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
N
=
10
class
TestEnsemble
(
torchani
.
testing
.
TestCase
):
class
TestEnsemble
(
TestCase
):
def
setUp
(
self
):
self
.
conformations
=
20
...
...
tests/test_forces.py
View file @
2007d181
...
...
@@ -3,12 +3,13 @@ import torchani
import
unittest
import
os
import
pickle
from
torchani.testing
import
TestCase
path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
N
=
97
class
TestForce
(
torchani
.
testing
.
TestCase
):
class
TestForce
(
TestCase
):
def
setUp
(
self
):
model
=
torchani
.
models
.
ANI1x
(
model_index
=
0
)
...
...
tests/test_grad.py
View file @
2007d181
...
...
@@ -3,11 +3,12 @@ import torchani
import
unittest
import
os
import
pickle
from
torchani.testing
import
TestCase
path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
class
TestGrad
(
torchani
.
testing
.
TestCase
):
class
TestGrad
(
TestCase
):
# torch.autograd.gradcheck and torch.autograd.gradgradcheck verify that
# the numerical and analytical gradient and hessian of a function
# matches to within a given tolerance.
...
...
tests/test_jit_builtin_models.py
View file @
2007d181
...
...
@@ -2,13 +2,14 @@ import torch
import
torchani
import
unittest
import
os
from
torchani.testing
import
TestCase
path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
dspath
=
os
.
path
.
join
(
path
,
'../dataset/ani-1x/sample.h5'
)
class
TestBuiltinModelsJIT
(
torchani
.
testing
.
TestCase
):
class
TestBuiltinModelsJIT
(
TestCase
):
# Tests if JIT compiled models have the same output energies
# as eager (non JIT) models
...
...
tests/test_neurochem.py
View file @
2007d181
...
...
@@ -2,6 +2,7 @@ import torchani
import
torch
import
os
import
unittest
from
torchani.testing
import
TestCase
path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
...
...
@@ -9,7 +10,7 @@ iptpath = os.path.join(path, 'test_data/inputtrain.ipt')
dspath
=
os
.
path
.
join
(
path
,
'../dataset/ani1-up_to_gdb4/ani_gdb_s01.h5'
)
class
TestNeuroChem
(
torchani
.
testing
.
TestCase
):
class
TestNeuroChem
(
TestCase
):
def
testNeuroChemTrainer
(
self
):
d
=
torch
.
device
(
'cuda'
if
torch
.
cuda
.
is_available
()
else
'cpu'
)
...
...
tests/test_padding.py
View file @
2007d181
import
unittest
import
torch
import
torchani
from
torchani.testing
import
TestCase
b
=
torchani
.
utils
.
broadcast_first_dim
class
TestPaddings
(
torchani
.
testing
.
TestCase
):
class
TestPaddings
(
TestCase
):
def
testVectorSpecies
(
self
):
species1
=
torch
.
tensor
([[
0
,
2
,
3
,
1
]])
...
...
@@ -90,7 +91,7 @@ class TestPaddings(torchani.testing.TestCase):
self
.
assertEqual
(
expected
,
present_species
)
class
TestStripRedundantPadding
(
torchani
.
testing
.
TestCase
):
class
TestStripRedundantPadding
(
TestCase
):
def
testStripRestore
(
self
):
species1
=
torch
.
randint
(
4
,
(
5
,
4
),
dtype
=
torch
.
long
)
...
...
tests/test_periodic_table_indexing.py
View file @
2007d181
import
unittest
import
torch
import
torchani
from
torchani.testing
import
TestCase
class
TestSpeciesConverter
(
torchani
.
testing
.
TestCase
):
class
TestSpeciesConverter
(
TestCase
):
def
setUp
(
self
):
self
.
c
=
torchani
.
SpeciesConverter
([
'H'
,
'C'
,
'N'
,
'O'
])
...
...
@@ -29,7 +30,7 @@ class TestSpeciesConverterJIT(TestSpeciesConverter):
self
.
c
=
torch
.
jit
.
script
(
self
.
c
)
class
TestBuiltinEnsemblePeriodicTableIndex
(
torchani
.
testing
.
TestCase
):
class
TestBuiltinEnsemblePeriodicTableIndex
(
TestCase
):
def
setUp
(
self
):
self
.
model1
=
torchani
.
models
.
ANI1x
()
...
...
tests/test_structure_optim.py
View file @
2007d181
...
...
@@ -6,12 +6,13 @@ import copy
import
pickle
from
ase.optimize
import
BFGS
from
ase
import
Atoms
from
torchani.testing
import
TestCase
path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
class
TestStructureOptimization
(
torchani
.
testing
.
TestCase
):
class
TestStructureOptimization
(
TestCase
):
def
setUp
(
self
):
self
.
tolerance
=
1e-6
...
...
tests/test_utils.py
View file @
2007d181
import
unittest
import
torch
import
torchani
from
torchani.testing
import
TestCase
class
TestUtils
(
torchani
.
testing
.
TestCase
):
class
TestUtils
(
TestCase
):
def
testChemicalSymbolsToInts
(
self
):
str2i
=
torchani
.
utils
.
ChemicalSymbolsToInts
([
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
])
...
...
tests/test_vibrational.py
View file @
2007d181
...
...
@@ -7,13 +7,14 @@ import ase
import
ase.optimize
import
ase.vibrations
import
numpy
from
torchani.testing
import
TestCase
path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
path
=
os
.
path
.
join
(
path
,
'../dataset/xyz_files/H2O.xyz'
)
class
TestVibrational
(
torchani
.
testing
.
TestCase
):
class
TestVibrational
(
TestCase
):
def
testVibrationalWavenumbers
(
self
):
model
=
torchani
.
models
.
ANI1x
().
double
()
...
...
torchani/__init__.py
View file @
2007d181
...
...
@@ -38,7 +38,6 @@ from . import models
from
.
import
units
from
pkg_resources
import
get_distribution
,
DistributionNotFound
import
warnings
from
.
import
testing
try
:
__version__
=
get_distribution
(
__name__
).
version
...
...
@@ -47,7 +46,7 @@ except DistributionNotFound:
pass
__all__
=
[
'AEVComputer'
,
'EnergyShifter'
,
'ANIModel'
,
'Ensemble'
,
'SpeciesConverter'
,
'utils'
,
'neurochem'
,
'models'
,
'units'
,
'testing'
]
'utils'
,
'neurochem'
,
'models'
,
'units'
]
try
:
from
.
import
ase
# noqa: F401
...
...
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