Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gext
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michele Nottoli
gext
Commits
0ae1eed9
Commit
0ae1eed9
authored
1 year ago
by
Michele Nottoli
Browse files
Options
Downloads
Patches
Plain Diff
Added a test for time reversibility.
parent
665c1d5e
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!6
QTR
Checking pipeline status
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_descriptor_fitting.py
+41
-0
41 additions, 0 deletions
tests/test_descriptor_fitting.py
with
41 additions
and
0 deletions
tests/test_descriptor_fitting.py
+
41
−
0
View file @
0ae1eed9
...
...
@@ -88,3 +88,44 @@ def test_quasi_time_reversible(datafile, regularization):
fitted_target
=
fitting_calculator
.
linear_combination
(
vectors
,
fit_coefficients
)
error
=
np
.
linalg
.
norm
(
target
-
fitted_target
,
ord
=
np
.
inf
)
assert
error
<
THRESHOLD
@pytest.mark.parametrize
(
"
datafile
"
,
[
"
urea.json
"
,
"
glucose.json
"
])
def
test_time_reversibility
(
datafile
):
# load test data from json file
data
=
utils
.
load_json
(
f
"
tests/
{
datafile
}
"
)
nelectrons
=
data
[
"
nelectrons
"
]
natoms
=
data
[
"
trajectory
"
].
shape
[
1
]
nbasis
=
data
[
"
overlaps
"
].
shape
[
1
]
nframes
=
data
[
"
trajectory
"
].
shape
[
0
]
# initialize an extrapolator
extrapolator
=
gext
.
Extrapolator
(
nelectrons
,
nbasis
,
natoms
,
nsteps
=
nframes
,
fitting
=
"
qtr
"
)
# load data in the extrapolator
for
(
coords
,
coeff
,
overlap
)
in
zip
(
data
[
"
trajectory
"
],
data
[
"
coefficients
"
],
data
[
"
overlaps
"
]):
extrapolator
.
load_data
(
coords
,
coeff
,
overlap
)
descriptors
=
extrapolator
.
descriptors
.
get
(
10
)
# we symmetrize the future and past targets (remember that it is
# quasi time reversible, not exactly time reversible)
target
=
descriptors
[
0
]
+
descriptors
[
-
1
]
descriptors
[
0
]
=
target
descriptors
[
-
1
]
=
target
fitting_calculator
=
extrapolator
.
fitting_calculator
# fit the future target
fit_coefficients
=
fitting_calculator
.
fit
(
descriptors
[:
-
1
],
descriptors
[
-
1
])
fitted_target
=
fitting_calculator
.
linear_combination
(
descriptors
[:
-
1
],
fit_coefficients
)
# fit the past target
reversed_descriptors
=
list
(
reversed
(
descriptors
))
fit_coefficients
=
fitting_calculator
.
fit
(
reversed_descriptors
[:
-
1
],
reversed_descriptors
[
-
1
])
fitted_target_reverse
=
fitting_calculator
.
linear_combination
(
reversed_descriptors
[:
-
1
],
fit_coefficients
)
# check the time reversibility
assert
np
.
linalg
.
norm
(
fitted_target
-
fitted_target_reverse
,
ord
=
np
.
inf
)
<
SMALL
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment