Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
2dfde4c2
Commit
2dfde4c2
authored
May 29, 2018
by
Martin Reinecke
Browse files
more energy test improvements
parent
597286b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
nifty4/extra/energy_tests.py
View file @
2dfde4c2
...
...
@@ -52,7 +52,6 @@ def check_value_gradient_consistency(E, tol=1e-6, ntries=100):
dir
=
E2
.
position
-
E
.
position
Enext
=
E2
dirnorm
=
dir
.
norm
()
dirder
=
E
.
gradient
.
vdot
(
dir
)
/
dirnorm
for
i
in
range
(
50
):
Emid
=
E
.
at
(
E
.
position
+
0.5
*
dir
)
dirder
=
Emid
.
gradient
.
vdot
(
dir
)
/
dirnorm
...
...
@@ -69,19 +68,20 @@ def check_value_gradient_consistency(E, tol=1e-6, ntries=100):
def
check_value_gradient_curvature_consistency
(
E
,
tol
=
1e-6
,
ntries
=
100
):
for
_
in
range
(
ntries
):
E2
=
_get_acceptable_energy
(
E
)
val
=
E
.
value
dir
=
E2
.
position
-
E
.
position
Enext
=
E2
dirnorm
=
dir
.
norm
()
dirder
=
E
.
gradient
.
vdot
(
dir
)
/
dirnorm
dgrad
=
E
.
curvature
(
dir
)
/
dirnorm
for
i
in
range
(
50
):
gdiff
=
E2
.
gradient
-
E
.
gradient
if
abs
((
E2
.
value
-
E
.
value
)
/
dirnorm
-
dirder
)
<
tol
and
\
Emid
=
E
.
at
(
E
.
position
+
0.5
*
dir
)
dirder
=
Emid
.
gradient
.
vdot
(
dir
)
/
dirnorm
dgrad
=
Emid
.
curvature
(
dir
)
/
dirnorm
if
abs
((
E2
.
value
-
val
)
/
dirnorm
-
dirder
)
<
tol
and
\
(
abs
((
E2
.
gradient
-
E
.
gradient
)
/
dirnorm
-
dgrad
)
<
tol
).
all
():
break
dir
*=
0.5
dirnorm
*=
0.5
E2
=
E
2
.
at
(
E
.
position
+
dir
)
E2
=
E
mid
else
:
raise
ValueError
(
"gradient, value and curvature seem inconsistent"
)
# E = Enext
nifty4/sugar.py
View file @
2dfde4c2
...
...
@@ -70,6 +70,7 @@ def get_signal_variance(spec, space):
k_field
=
dist
(
field
)
return
k_field
.
weight
(
2
).
sum
()
def
_single_power_analyze
(
field
,
idx
,
binbounds
):
power_domain
=
PowerSpace
(
field
.
domain
[
idx
],
binbounds
)
pd
=
PowerDistributor
(
field
.
domain
,
power_domain
,
idx
)
...
...
test/test_multi_field.py
View file @
2dfde4c2
...
...
@@ -25,6 +25,7 @@ from test.common import expand
dom
=
ift
.
makeDomain
({
"d1"
:
ift
.
RGSpace
(
10
)})
class
Test_Functionality
(
unittest
.
TestCase
):
def
test_vdot
(
self
):
f1
=
ift
.
from_random
(
"normal"
,
domain
=
dom
,
dtype
=
np
.
complex128
)
...
...
@@ -53,7 +54,8 @@ class Test_Functionality(unittest.TestCase):
assert_equal
(
val
.
local_data
,
f2
[
key
].
local_data
)
def
test_blockdiagonal
(
self
):
op
=
ift
.
BlockDiagonalOperator
({
"d1"
:
ift
.
ScalingOperator
(
20.
,
dom
[
"d1"
])})
op
=
ift
.
BlockDiagonalOperator
({
"d1"
:
ift
.
ScalingOperator
(
20.
,
dom
[
"d1"
])})
op2
=
op
*
op
ift
.
extra
.
consistency_check
(
op2
)
assert_equal
(
type
(
op2
),
ift
.
BlockDiagonalOperator
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment