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
ift
NIFTy
Commits
ecd9ca14
Commit
ecd9ca14
authored
Feb 18, 2018
by
Martin Reinecke
Browse files
more syntactic sugar
parent
fa44604e
Pipeline
#25091
passed with stages
in 6 minutes and 45 seconds
Changes
20
Pipelines
1
Show whitespace changes
Inline
Side-by-side
demos/nonlinear_critical_filter.py
View file @
ecd9ca14
...
...
@@ -33,7 +33,7 @@ if __name__ == "__main__":
p_space
=
ift
.
PowerSpace
(
h_space
,
binbounds
=
ift
.
PowerSpace
.
useful_binbounds
(
h_space
,
logarithmic
=
True
))
s_spec
=
ift
.
Field
(
p_space
,
val
=
1.
)
s_spec
=
ift
.
Field
.
full
(
p_space
,
1.
)
# Choosing the prior correlation structure and defining
# correlation operator
p
=
ift
.
PS_field
(
p_space
,
p_spec
)
...
...
@@ -41,8 +41,7 @@ if __name__ == "__main__":
S
=
ift
.
create_power_operator
(
h_space
,
power_spectrum
=
s_spec
)
# Drawing a sample sh from the prior distribution in harmonic space
sp
=
ift
.
Field
(
p_space
,
val
=
s_spec
)
sh
=
ift
.
power_synthesize
(
sp
)
sh
=
ift
.
power_synthesize
(
s_spec
)
# Choosing the measurement instrument
# Instrument = SmoothingOperator(s_space, sigma=0.01)
...
...
@@ -73,8 +72,8 @@ if __name__ == "__main__":
# Creating the mock data
d
=
noiseless_data
+
n
m0
=
ift
.
power_synthesize
(
ift
.
Field
(
p_space
,
val
=
1e-7
))
t0
=
ift
.
Field
(
p_space
,
val
=
-
4.
)
m0
=
ift
.
power_synthesize
(
ift
.
Field
.
full
(
p_space
,
1e-7
))
t0
=
ift
.
Field
.
full
(
p_space
,
-
4.
)
power0
=
Distributor
.
times
(
ift
.
exp
(
0.5
*
t0
))
IC1
=
ift
.
GradientNormController
(
name
=
"IC1"
,
iteration_limit
=
100
,
...
...
demos/paper_demos/cartesian_wiener_filter.py
View file @
ecd9ca14
...
...
@@ -100,13 +100,13 @@ if __name__ == "__main__":
plotdict
=
{
"colormap"
:
"Planck-like"
}
plot_space
=
ift
.
RGSpace
((
N_pixels_1
,
N_pixels_2
))
ift
.
plot
(
ift
.
Field
(
plot_space
,
val
=
ht
(
mock_signal
).
val
),
ift
.
plot
(
ht
(
mock_signal
).
cast_domain
(
plot_space
),
name
=
'mock_signal.png'
,
**
plotdict
)
ift
.
plot
(
ift
.
Field
(
plot_space
,
val
=
data
.
val
),
name
=
'data.png'
,
**
plotdict
)
ift
.
plot
(
ift
.
Field
(
plot_space
,
val
=
m
.
val
),
name
=
'map.png'
,
**
plotdict
)
ift
.
plot
(
data
.
cast_domain
(
plot_space
),
name
=
'data.png'
,
**
plotdict
)
ift
.
plot
(
m
.
cast_domain
(
plot_space
),
name
=
'map.png'
,
**
plotdict
)
# sampling the uncertainty map
mean
,
variance
=
ift
.
probe_with_posterior_samples
(
wiener_curvature
,
ht
,
10
)
ift
.
plot
(
ift
.
Field
(
plot_space
,
val
=
ift
.
sqrt
(
variance
).
val
),
ift
.
plot
(
ift
.
sqrt
(
variance
).
cast_domain
(
plot_space
),
name
=
"uncertainty.png"
,
**
plotdict
)
ift
.
plot
(
ift
.
Field
(
plot_space
,
val
=
(
mean
+
m
).
val
),
ift
.
plot
(
(
mean
+
m
).
cast_domain
(
plot_space
),
name
=
"posterior_mean.png"
,
**
plotdict
)
demos/paper_demos/wiener_filter.py
View file @
ecd9ca14
...
...
@@ -62,8 +62,7 @@ if __name__ == "__main__":
plotdict
=
{
"colormap"
:
"Planck-like"
}
ift
.
plot
(
ht
(
mock_signal
),
name
=
"mock_signal.png"
,
**
plotdict
)
ift
.
plot
(
ift
.
Field
(
signal_space
,
val
=
data
.
val
),
name
=
"data.png"
,
**
plotdict
)
ift
.
plot
(
data
.
cast_domain
(
signal_space
),
name
=
"data.png"
,
**
plotdict
)
ift
.
plot
(
m
,
name
=
"map.png"
,
**
plotdict
)
# sampling the uncertainty map
...
...
demos/wiener_filter_easy.py
View file @
ecd9ca14
...
...
@@ -64,7 +64,7 @@ if __name__ == "__main__":
m
=
D
(
j
)
# Plotting
d_field
=
ift
.
Field
(
s_space
,
val
=
d
.
val
)
d_field
=
d
.
cast_domain
(
s_space
)
zmax
=
max
(
HT
(
sh
).
max
(),
d_field
.
max
(),
HT
(
m
).
max
())
zmin
=
min
(
HT
(
sh
).
min
(),
d_field
.
min
(),
HT
(
m
).
min
())
plotdict
=
{
"colormap"
:
"Planck-like"
,
"zmax"
:
zmax
,
"zmin"
:
zmin
}
...
...
demos/wiener_filter_via_curvature.py
View file @
ecd9ca14
...
...
@@ -94,8 +94,8 @@ if __name__ == "__main__":
zmin
=
min
(
m_s
.
min
(),
HT
(
mock_signal
).
min
())
plotdict
=
{
"zmax"
:
zmax
/
nu
.
K
,
"zmin"
:
zmin
/
nu
.
K
}
ift
.
plot
(
ift
.
Field
(
sspace2
,
HT
(
mock_signal
)
.
val
)
/
nu
.
K
,
ift
.
plot
(
(
HT
(
mock_signal
)
/
nu
.
K
).
cast_domain
(
sspace2
)
,
name
=
"mock_signal.png"
,
**
plotdict
)
ift
.
plot
(
ift
.
Field
(
sspace2
,
val
=
data
.
val
),
name
=
"data.png"
)
ift
.
plot
(
ift
.
Field
(
sspace2
,
m_s
.
val
)
/
nu
.
K
,
name
=
"reconstruction.png"
,
ift
.
plot
(
data
.
cast_domain
(
sspace2
),
name
=
"data.png"
)
ift
.
plot
(
(
m_s
/
nu
.
K
).
cast_domain
(
sspace2
)
,
name
=
"reconstruction.png"
,
**
plotdict
)
nifty4/extra/operator_tests.py
View file @
ecd9ca14
...
...
@@ -27,9 +27,9 @@ def adjoint_implementation(op, domain_dtype, target_dtype, atol, rtol):
needed_cap
=
op
.
TIMES
|
op
.
ADJOINT_TIMES
if
(
op
.
capability
&
needed_cap
)
!=
needed_cap
:
return
f1
=
Field
.
from_random
(
"normal"
,
op
.
domain
,
dtype
=
domain_dtype
)
f2
=
Field
.
from_random
(
"normal"
,
op
.
target
,
dtype
=
target_dtype
)
res1
=
f1
.
vdot
(
op
.
adjoint_times
(
f2
))
f1
=
Field
.
from_random
(
"normal"
,
op
.
domain
,
dtype
=
domain_dtype
)
.
lock
()
f2
=
Field
.
from_random
(
"normal"
,
op
.
target
,
dtype
=
target_dtype
)
.
lock
()
res1
=
f1
.
vdot
(
op
.
adjoint_times
(
f2
)
.
lock
()
)
res2
=
op
.
times
(
f1
).
vdot
(
f2
)
np
.
testing
.
assert_allclose
(
res1
,
res2
,
atol
=
atol
,
rtol
=
rtol
)
...
...
@@ -38,16 +38,14 @@ def inverse_implementation(op, domain_dtype, target_dtype, atol, rtol):
needed_cap
=
op
.
TIMES
|
op
.
INVERSE_TIMES
if
(
op
.
capability
&
needed_cap
)
!=
needed_cap
:
return
foo
=
Field
.
from_random
(
"normal"
,
op
.
target
,
dtype
=
target_dtype
)
res
=
op
(
op
.
inverse_times
(
foo
))
np
.
testing
.
assert_allclose
(
dobj
.
to_global_data
(
res
.
val
),
dobj
.
to_global_data
(
foo
.
val
),
foo
=
Field
.
from_random
(
"normal"
,
op
.
target
,
dtype
=
target_dtype
).
lock
()
res
=
op
(
op
.
inverse_times
(
foo
).
lock
())
np
.
testing
.
assert_allclose
(
res
.
to_global_data
(),
res
.
to_global_data
(),
atol
=
atol
,
rtol
=
rtol
)
foo
=
Field
.
from_random
(
"normal"
,
op
.
domain
,
dtype
=
domain_dtype
)
res
=
op
.
inverse_times
(
op
(
foo
))
np
.
testing
.
assert_allclose
(
dobj
.
to_global_data
(
res
.
val
),
dobj
.
to_global_data
(
foo
.
val
),
foo
=
Field
.
from_random
(
"normal"
,
op
.
domain
,
dtype
=
domain_dtype
).
lock
()
res
=
op
.
inverse_times
(
op
(
foo
).
lock
())
np
.
testing
.
assert_allclose
(
res
.
to_global_data
(),
foo
.
to_global_data
(),
atol
=
atol
,
rtol
=
rtol
)
...
...
nifty4/field.py
View file @
ecd9ca14
...
...
@@ -130,6 +130,9 @@ class Field(object):
def
to_global_data
(
self
):
return
dobj
.
to_global_data
(
self
.
_val
)
def
cast_domain
(
self
,
new_domain
):
return
Field
(
new_domain
,
self
.
_val
)
@
staticmethod
def
_infer_domain
(
domain
,
val
=
None
):
if
domain
is
None
:
...
...
nifty4/operators/geometry_remover.py
View file @
ecd9ca14
...
...
@@ -47,5 +47,5 @@ class GeometryRemover(LinearOperator):
def
apply
(
self
,
x
,
mode
):
self
.
_check_input
(
x
,
mode
)
if
mode
==
self
.
TIMES
:
return
Field
(
self
.
_target
,
val
=
x
.
weight
(
1
).
val
)
return
Field
(
self
.
_domain
,
val
=
x
.
val
).
weight
(
1
)
return
x
.
weight
(
1
).
cast_domain
(
self
.
_target
)
return
x
.
cast_domain
(
self
.
_domain
).
weight
(
1
)
test/test_energies/test_map.py
View file @
ecd9ca14
...
...
@@ -161,8 +161,8 @@ class Curvature_Tests(unittest.TestCase):
a
=
(
gradient1
-
gradient0
)
/
eps
b
=
energy0
.
curvature
(
direction
)
tol
=
1e-7
assert_allclose
(
ift
.
dobj
.
to_global_data
(
a
.
val
),
ift
.
dobj
.
to_global_data
(
b
.
val
),
rtol
=
tol
,
atol
=
tol
)
assert_allclose
(
a
.
to_global_data
(
),
b
.
to_global_data
(
),
rtol
=
tol
,
atol
=
tol
)
@
expand
(
product
([
ift
.
RGSpace
(
64
,
distances
=
.
789
),
ift
.
RGSpace
([
32
,
32
],
distances
=
.
789
)],
...
...
@@ -217,5 +217,5 @@ class Curvature_Tests(unittest.TestCase):
a
=
(
gradient1
-
gradient0
)
/
eps
b
=
energy0
.
curvature
(
direction
)
tol
=
1e-7
assert_allclose
(
ift
.
dobj
.
to_global_data
(
a
.
val
),
ift
.
dobj
.
to_global_data
(
b
.
val
),
rtol
=
tol
,
atol
=
tol
)
assert_allclose
(
a
.
to_global_data
(
),
b
.
to_global_data
(
),
rtol
=
tol
,
atol
=
tol
)
test/test_energies/test_noise.py
View file @
ecd9ca14
...
...
@@ -52,15 +52,15 @@ class Noise_Energy_Tests(unittest.TestCase):
domain
=
space
,
random_type
=
'normal'
,
std
=
np
.
sqrt
(
var
))
var
=
ift
.
Field
(
n
.
domain
,
val
=
var
)
var
=
ift
.
Field
.
full
(
n
.
domain
,
var
)
N
=
ift
.
DiagonalOperator
(
var
)
eta0
=
ift
.
log
(
var
)
s
=
ht
(
xi
*
A
)
R
=
ift
.
ScalingOperator
(
10.
,
space
)
d
=
R
(
f
(
s
))
+
n
alpha
=
ift
.
Field
(
d
.
domain
,
val
=
2.
)
q
=
ift
.
Field
(
d
.
domain
,
val
=
1e-5
)
alpha
=
ift
.
Field
.
full
(
d
.
domain
,
2.
)
q
=
ift
.
Field
.
full
(
d
.
domain
,
1e-5
)
direction
=
ift
.
Field
.
from_random
(
'normal'
,
d
.
domain
)
direction
/=
np
.
sqrt
(
direction
.
var
())
...
...
test/test_energies/test_power.py
View file @
ecd9ca14
...
...
@@ -199,5 +199,5 @@ class Curvature_Tests(unittest.TestCase):
a
=
(
gradient1
-
gradient0
)
/
eps
b
=
energy0
.
curvature
(
direction
)
tol
=
1e-5
assert_allclose
(
ift
.
dobj
.
to_global_data
(
a
.
val
),
ift
.
dobj
.
to_global_data
(
b
.
val
),
rtol
=
tol
,
atol
=
tol
)
assert_allclose
(
a
.
to_global_data
(
),
b
.
to_global_data
(
),
rtol
=
tol
,
atol
=
tol
)
test/test_field.py
View file @
ecd9ca14
...
...
@@ -37,7 +37,7 @@ class Test_Interface(unittest.TestCase):
def
test_return_types
(
self
,
domain
,
attribute_desired_type
):
attribute
=
attribute_desired_type
[
0
]
desired_type
=
attribute_desired_type
[
1
]
f
=
ift
.
Field
(
domain
=
domain
,
val
=
1.
)
f
=
ift
.
Field
.
full
(
domain
,
1.
)
assert_equal
(
isinstance
(
getattr
(
f
,
attribute
),
desired_type
),
True
)
...
...
@@ -133,6 +133,6 @@ class Test_Functionality(unittest.TestCase):
def
test_vdot2
(
self
):
x1
=
ift
.
RGSpace
((
200
,))
x2
=
ift
.
RGSpace
((
150
,))
m
=
ift
.
Field
((
x1
,
x2
),
val
=
.
5
)
m
=
ift
.
Field
.
full
((
x1
,
x2
),
.
5
)
res
=
m
.
vdot
(
m
,
spaces
=
1
)
assert_allclose
(
res
.
to_global_data
(),
37.5
)
test/test_minimization/test_minimizers.py
View file @
ecd9ca14
...
...
@@ -53,8 +53,8 @@ class Test_Minimizers(unittest.TestCase):
raise
SkipTest
assert_equal
(
convergence
,
IC
.
CONVERGED
)
assert_allclose
(
ift
.
dobj
.
to_global_data
(
energy
.
position
.
val
),
1.
/
ift
.
dobj
.
to_global_data
(
covariance_diagonal
.
val
),
assert_allclose
(
energy
.
position
.
to_global_data
(),
1.
/
covariance_diagonal
.
to_global_data
(
),
rtol
=
1e-3
,
atol
=
1e-3
)
...
...
test/test_operators/test_adjoint.py
View file @
ecd9ca14
...
...
@@ -76,3 +76,9 @@ class Consistency_Tests(unittest.TestCase):
def
testSmoothness
(
self
,
sp
,
dtype
):
op
=
ift
.
SmoothnessOperator
(
sp
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
@
expand
(
product
(
_h_spaces
+
_p_spaces
+
_pow_spaces
,
[
np
.
float64
,
np
.
complex128
]))
def
testGeometryRemover
(
self
,
sp
,
dtype
):
op
=
ift
.
GeometryRemover
(
sp
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
test/test_operators/test_composed_operator.py
View file @
ecd9ca14
...
...
@@ -57,35 +57,34 @@ class ComposedOperator_Tests(unittest.TestCase):
rand1
=
ift
.
Field
.
from_random
(
'normal'
,
domain
=
(
space1
,
space2
))
tt1
=
op
.
inverse_times
(
op
.
times
(
rand1
))
assert_allclose
(
ift
.
dobj
.
to_global_data
(
tt1
.
val
),
ift
.
dobj
.
to_global_data
(
rand1
.
val
))
assert_allclose
(
tt1
.
to_global_data
(),
rand1
.
to_global_data
())
@
expand
(
product
(
spaces
))
def
test_sum
(
self
,
space
):
op1
=
ift
.
DiagonalOperator
(
ift
.
Field
(
space
,
2.
))
op1
=
ift
.
DiagonalOperator
(
ift
.
Field
.
full
(
space
,
2.
))
op2
=
ift
.
ScalingOperator
(
3.
,
space
)
full_op
=
op1
+
op2
-
(
op2
-
op1
)
+
op1
+
op1
+
op2
x
=
ift
.
Field
(
space
,
1.
)
x
=
ift
.
Field
.
full
(
space
,
1.
)
res
=
full_op
(
x
)
assert_equal
(
isinstance
(
full_op
,
ift
.
DiagonalOperator
),
True
)
assert_allclose
(
ift
.
dobj
.
to_global_data
(
res
.
val
),
11.
)
assert_allclose
(
res
.
to_global_data
(),
11.
)
@
expand
(
product
(
spaces
))
def
test_chain
(
self
,
space
):
op1
=
ift
.
DiagonalOperator
(
ift
.
Field
(
space
,
2.
))
op1
=
ift
.
DiagonalOperator
(
ift
.
Field
.
full
(
space
,
2.
))
op2
=
ift
.
ScalingOperator
(
3.
,
space
)
full_op
=
op1
*
op2
*
(
op2
*
op1
)
*
op1
*
op1
*
op2
x
=
ift
.
Field
(
space
,
1.
)
x
=
ift
.
Field
.
full
(
space
,
1.
)
res
=
full_op
(
x
)
assert_equal
(
isinstance
(
full_op
,
ift
.
DiagonalOperator
),
True
)
assert_allclose
(
ift
.
dobj
.
to_global_data
(
res
.
val
),
432.
)
assert_allclose
(
res
.
to_global_data
(),
432.
)
@
expand
(
product
(
spaces
))
def
test_mix
(
self
,
space
):
op1
=
ift
.
DiagonalOperator
(
ift
.
Field
(
space
,
2.
))
op1
=
ift
.
DiagonalOperator
(
ift
.
Field
.
full
(
space
,
2.
))
op2
=
ift
.
ScalingOperator
(
3.
,
space
)
full_op
=
op1
*
(
op2
+
op2
)
*
op1
*
op1
-
op1
*
op2
x
=
ift
.
Field
(
space
,
1.
)
x
=
ift
.
Field
.
full
(
space
,
1.
)
res
=
full_op
(
x
)
assert_equal
(
isinstance
(
full_op
,
ift
.
DiagonalOperator
),
True
)
assert_allclose
(
ift
.
dobj
.
to_global_data
(
res
.
val
),
42.
)
assert_allclose
(
res
.
to_global_data
(),
42.
)
test/test_operators/test_diagonal_operator.py
View file @
ecd9ca14
...
...
@@ -51,8 +51,7 @@ class DiagonalOperator_Tests(unittest.TestCase):
diag
=
ift
.
Field
.
from_random
(
'normal'
,
domain
=
space
)
D
=
ift
.
DiagonalOperator
(
diag
)
tt1
=
D
.
times
(
D
.
inverse_times
(
rand1
))
assert_allclose
(
ift
.
dobj
.
to_global_data
(
rand1
.
val
),
ift
.
dobj
.
to_global_data
(
tt1
.
val
))
assert_allclose
(
rand1
.
to_global_data
(),
tt1
.
to_global_data
())
@
expand
(
product
(
spaces
))
def
test_times
(
self
,
space
):
...
...
@@ -91,5 +90,4 @@ class DiagonalOperator_Tests(unittest.TestCase):
diag
=
ift
.
Field
.
from_random
(
'normal'
,
domain
=
space
)
D
=
ift
.
DiagonalOperator
(
diag
)
diag_op
=
D
.
diagonal
assert_allclose
(
ift
.
dobj
.
to_global_data
(
diag
.
val
),
ift
.
dobj
.
to_global_data
(
diag_op
.
val
))
assert_allclose
(
diag
.
to_global_data
(),
diag_op
.
to_global_data
())
test/test_operators/test_fft_operator.py
View file @
ecd9ca14
...
...
@@ -45,8 +45,8 @@ class FFTOperatorTests(unittest.TestCase):
inp
=
ift
.
Field
.
from_random
(
domain
=
a
,
random_type
=
'normal'
,
std
=
7
,
mean
=
3
,
dtype
=
itp
)
out
=
fft
.
inverse_times
(
fft
.
times
(
inp
))
assert_allclose
(
i
ft
.
dobj
.
to_global_data
(
inp
.
val
),
ift
.
dobj
.
to_global_data
(
out
.
val
),
rtol
=
tol
,
atol
=
tol
)
assert_allclose
(
i
np
.
to_global_data
(
),
out
.
to_global_data
(
),
rtol
=
tol
,
atol
=
tol
)
a
,
b
=
b
,
a
...
...
@@ -54,8 +54,8 @@ class FFTOperatorTests(unittest.TestCase):
inp
=
ift
.
Field
.
from_random
(
domain
=
a
,
random_type
=
'normal'
,
std
=
7
,
mean
=
3
,
dtype
=
itp
)
out
=
fft
.
inverse_times
(
fft
.
times
(
inp
))
assert_allclose
(
i
ft
.
dobj
.
to_global_data
(
inp
.
val
),
ift
.
dobj
.
to_global_data
(
out
.
val
),
rtol
=
tol
,
atol
=
tol
)
assert_allclose
(
i
np
.
to_global_data
(
),
out
.
to_global_data
(
),
rtol
=
tol
,
atol
=
tol
)
@
expand
(
product
([
12
,
15
],
[
9
,
12
],
[
0.1
,
1
,
3.7
],
[
0.4
,
1
,
2.7
],
...
...
@@ -70,9 +70,8 @@ class FFTOperatorTests(unittest.TestCase):
inp
=
ift
.
Field
.
from_random
(
domain
=
a
,
random_type
=
'normal'
,
std
=
7
,
mean
=
3
,
dtype
=
itp
)
out
=
fft
.
inverse_times
(
fft
.
times
(
inp
))
assert_allclose
(
ift
.
dobj
.
to_global_data
(
inp
.
val
),
ift
.
dobj
.
to_global_data
(
out
.
val
),
rtol
=
tol
,
atol
=
tol
)
fft
=
ift
.
FFTOperator
(
domain
=
a
,
target
=
b
)
assert_allclose
(
inp
.
to_global_data
(),
out
.
to_global_data
(),
rtol
=
tol
,
atol
=
tol
)
a
,
b
=
b
,
a
...
...
@@ -80,8 +79,8 @@ class FFTOperatorTests(unittest.TestCase):
inp
=
ift
.
Field
.
from_random
(
domain
=
a
,
random_type
=
'normal'
,
std
=
7
,
mean
=
3
,
dtype
=
itp
)
out
=
fft
.
inverse_times
(
fft
.
times
(
inp
))
assert_allclose
(
i
ft
.
dobj
.
to_global_data
(
inp
.
val
),
ift
.
dobj
.
to_global_data
(
out
.
val
),
rtol
=
tol
,
atol
=
tol
)
assert_allclose
(
i
np
.
to_global_data
(
),
out
.
to_global_data
(
),
rtol
=
tol
,
atol
=
tol
)
@
expand
(
product
([
0
,
1
,
2
],
[
np
.
float64
,
np
.
float32
,
np
.
complex64
,
np
.
complex128
]))
...
...
@@ -94,8 +93,8 @@ class FFTOperatorTests(unittest.TestCase):
inp
=
ift
.
Field
.
from_random
(
domain
=
(
a1
,
a2
,
a3
),
random_type
=
'normal'
,
std
=
7
,
mean
=
3
,
dtype
=
dtype
)
out
=
fft
.
inverse_times
(
fft
.
times
(
inp
))
assert_allclose
(
i
ft
.
dobj
.
to_global_data
(
inp
.
val
),
ift
.
dobj
.
to_global_data
(
out
.
val
),
rtol
=
tol
,
atol
=
tol
)
assert_allclose
(
i
np
.
to_global_data
(
),
out
.
to_global_data
(
),
rtol
=
tol
,
atol
=
tol
)
@
expand
(
product
([
ift
.
RGSpace
(
128
,
distances
=
3.76
,
harmonic
=
True
),
ift
.
RGSpace
((
15
,
27
),
distances
=
(.
7
,
.
33
),
harmonic
=
True
),
...
...
@@ -111,9 +110,7 @@ class FFTOperatorTests(unittest.TestCase):
fft2
=
ift
.
FFTOperator
(
cospace
,
space
)
out2
=
fft2
.
inverse_times
(
inp
)
zero_idx
=
tuple
([
0
]
*
len
(
space
.
shape
))
assert_allclose
(
ift
.
dobj
.
to_global_data
(
inp
.
val
)[
zero_idx
],
out
.
integrate
(),
assert_allclose
(
inp
.
to_global_data
()[
zero_idx
],
out
.
integrate
(),
rtol
=
tol
,
atol
=
tol
)
assert_allclose
(
ift
.
dobj
.
to_global_data
(
out
.
val
),
ift
.
dobj
.
to_global_data
(
out2
.
val
),
assert_allclose
(
out
.
to_global_data
(),
out2
.
to_global_data
(),
rtol
=
tol
,
atol
=
tol
)
test/test_operators/test_laplace_operator.py
View file @
ecd9ca14
...
...
@@ -46,4 +46,4 @@ class LaplaceOperatorTests(unittest.TestCase):
result
=
np
.
full
(
p
.
shape
,
2
*
2.
)
result
[
0
]
=
result
[
1
]
=
result
[
-
1
]
=
0.
assert_allclose
(
ift
.
dobj
.
to_global_data
(
L
(
foo
).
val
),
result
)
assert_allclose
(
L
(
foo
)
.
to_global_data
(),
result
)
test/test_spaces/test_lm_space.py
View file @
ecd9ca14
...
...
@@ -92,5 +92,4 @@ class LMSpaceFunctionalityTests(unittest.TestCase):
@
expand
(
get_k_length_array_configs
())
def
test_k_length_array
(
self
,
lmax
,
expected
):
l
=
ift
.
LMSpace
(
lmax
)
assert_allclose
(
ift
.
dobj
.
to_global_data
(
l
.
get_k_length_array
().
val
),
expected
)
assert_allclose
(
l
.
get_k_length_array
().
to_global_data
(),
expected
)
test/test_spaces/test_rg_space.py
View file @
ecd9ca14
...
...
@@ -110,8 +110,7 @@ class RGSpaceFunctionalityTests(unittest.TestCase):
@
expand
(
get_k_length_array_configs
())
def
test_k_length_array
(
self
,
shape
,
distances
,
expected
):
r
=
ift
.
RGSpace
(
shape
=
shape
,
distances
=
distances
,
harmonic
=
True
)
assert_allclose
(
ift
.
dobj
.
to_global_data
(
r
.
get_k_length_array
().
val
),
expected
)
assert_allclose
(
r
.
get_k_length_array
().
to_global_data
(),
expected
)
@
expand
(
get_dvol_configs
())
def
test_dvol
(
self
,
shape
,
distances
,
harmonic
,
power
):
...
...
Write
Preview
Supports
Markdown
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