Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
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
ift
NIFTy
Commits
f1709dd5
Commit
f1709dd5
authored
6 years ago
by
Philipp Arras
Browse files
Options
Downloads
Patches
Plain Diff
Even more thorough automatic tests for (linear) operators
parent
ae0f9525
No related branches found
No related tags found
2 merge requests
!324
New gridder (again!)
,
!318
switch from numpy.fft to pypocketfft
Pipeline
#48150
failed
6 years ago
Stage: build_docker
Stage: test
Stage: demo_runs
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nifty5/extra.py
+11
-0
11 additions, 0 deletions
nifty5/extra.py
with
11 additions
and
0 deletions
nifty5/extra.py
+
11
−
0
View file @
f1709dd5
...
@@ -17,8 +17,10 @@
...
@@ -17,8 +17,10 @@
import
numpy
as
np
import
numpy
as
np
from
.domain_tuple
import
DomainTuple
from
.field
import
Field
from
.field
import
Field
from
.linearization
import
Linearization
from
.linearization
import
Linearization
from
.multi_domain
import
MultiDomain
from
.operators.linear_operator
import
LinearOperator
from
.operators.linear_operator
import
LinearOperator
from
.sugar
import
from_random
from
.sugar
import
from_random
...
@@ -76,6 +78,13 @@ def _check_linearity(op, domain_dtype, atol, rtol):
...
@@ -76,6 +78,13 @@ def _check_linearity(op, domain_dtype, atol, rtol):
_assert_allclose
(
val1
,
val2
,
atol
=
atol
,
rtol
=
rtol
)
_assert_allclose
(
val1
,
val2
,
atol
=
atol
,
rtol
=
rtol
)
def
_domain_check
(
op
):
for
dd
in
[
op
.
domain
,
op
.
target
]:
if
not
isinstance
(
dd
,
(
DomainTuple
,
MultiDomain
)):
raise
TypeError
(
'
The domain and the target of an operator need to
'
,
'
be instances of either DomainTuple or MultiDomain.
'
)
def
consistency_check
(
op
,
domain_dtype
=
np
.
float64
,
target_dtype
=
np
.
float64
,
def
consistency_check
(
op
,
domain_dtype
=
np
.
float64
,
target_dtype
=
np
.
float64
,
atol
=
0
,
rtol
=
1e-7
,
only_r_linear
=
False
):
atol
=
0
,
rtol
=
1e-7
,
only_r_linear
=
False
):
"""
"""
...
@@ -109,6 +118,7 @@ def consistency_check(op, domain_dtype=np.float64, target_dtype=np.float64,
...
@@ -109,6 +118,7 @@ def consistency_check(op, domain_dtype=np.float64, target_dtype=np.float64,
"""
"""
if
not
isinstance
(
op
,
LinearOperator
):
if
not
isinstance
(
op
,
LinearOperator
):
raise
TypeError
(
'
This test tests only linear operators.
'
)
raise
TypeError
(
'
This test tests only linear operators.
'
)
_domain_check
(
op
)
_check_linearity
(
op
,
domain_dtype
,
atol
,
rtol
)
_check_linearity
(
op
,
domain_dtype
,
atol
,
rtol
)
_full_implementation
(
op
,
domain_dtype
,
target_dtype
,
atol
,
rtol
,
_full_implementation
(
op
,
domain_dtype
,
target_dtype
,
atol
,
rtol
,
only_r_linear
)
only_r_linear
)
...
@@ -162,6 +172,7 @@ def check_jacobian_consistency(op, loc, tol=1e-8, ntries=100):
...
@@ -162,6 +172,7 @@ def check_jacobian_consistency(op, loc, tol=1e-8, ntries=100):
tol : float
tol : float
Tolerance for the check.
Tolerance for the check.
"""
"""
_domain_check
(
op
)
for
_
in
range
(
ntries
):
for
_
in
range
(
ntries
):
lin
=
op
(
Linearization
.
make_var
(
loc
))
lin
=
op
(
Linearization
.
make_var
(
loc
))
loc2
,
lin2
=
_get_acceptable_location
(
op
,
loc
,
lin
)
loc2
,
lin2
=
_get_acceptable_location
(
op
,
loc
,
lin
)
...
...
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