Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Neel Shah
NIFTy
Commits
4351c81a
Commit
4351c81a
authored
Nov 07, 2019
by
Philipp Arras
Browse files
Add jacobian test
parent
d304bf8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
nifty5/library/correlated_fields.py
View file @
4351c81a
...
...
@@ -128,7 +128,7 @@ class _Normalization(Operator):
def
__init__
(
self
,
domain
):
self
.
_domain
=
self
.
_target
=
makeDomain
(
domain
)
assert
len
(
self
.
_domain
)
==
1
assert
isinstance
(
domain
[
0
],
PowerSpace
)
assert
isinstance
(
self
.
_
domain
[
0
],
PowerSpace
)
hspace
=
self
.
_domain
[
0
].
harmonic_partner
pd
=
PowerDistributor
(
hspace
,
power_space
=
self
.
_domain
[
0
])
cst
=
pd
.
adjoint
(
full
(
pd
.
target
,
1.
)).
to_global_data_rw
()
...
...
test/test_operators/test_jacobian.py
View file @
4351c81a
...
...
@@ -29,6 +29,11 @@ space = list2fixture([
ift
.
RGSpace
(
64
,
distances
=
.
789
),
ift
.
RGSpace
([
32
,
32
],
distances
=
.
789
)
])
_h_RG_spaces
=
[
ift
.
RGSpace
(
7
,
distances
=
0.2
,
harmonic
=
True
),
ift
.
RGSpace
((
12
,
46
),
distances
=
(.
2
,
.
3
),
harmonic
=
True
)
]
_h_spaces
=
_h_RG_spaces
+
[
ift
.
LMSpace
(
17
)]
space1
=
space
seed
=
list2fixture
([
4
,
78
,
23
])
...
...
@@ -163,3 +168,20 @@ def testDynamicModel(target, causal, minimum_phase, seed):
# FIXME I dont know why smaller tol fails for 3D example
ift
.
extra
.
check_jacobian_consistency
(
model
,
pos
,
tol
=
1e-5
,
ntries
=
20
)
@
pmp
(
'h_space'
,
_h_spaces
)
@
pmp
(
'specialbinbounds'
,
[
True
,
False
])
@
pmp
(
'logarithmic'
,
[
True
,
False
])
@
pmp
(
'nbin'
,
[
3
,
None
])
def
testNormalization
(
h_space
,
specialbinbounds
,
logarithmic
,
nbin
):
if
not
specialbinbounds
and
(
not
logarithmic
or
nbin
is
not
None
):
return
if
specialbinbounds
:
binbounds
=
ift
.
PowerSpace
.
useful_binbounds
(
h_space
,
logarithmic
,
nbin
)
else
:
binbounds
=
None
dom
=
ift
.
PowerSpace
(
h_space
,
binbounds
)
op
=
ift
.
library
.
correlated_fields
.
_Normalization
(
dom
)
pos
=
0.1
*
ift
.
from_random
(
'normal'
,
op
.
domain
)
ift
.
extra
.
check_jacobian_consistency
(
op
,
pos
)
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