Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
15fc7b6d
Commit
15fc7b6d
authored
Aug 22, 2017
by
Martin Reinecke
Browse files
remove factory method; create the proper operators directly
parent
788af006
Pipeline
#17035
passed with stage
in 20 minutes and 8 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
demos/paper_demos/cartesian_wiener_filter.py
View file @
15fc7b6d
...
...
@@ -130,7 +130,7 @@ if __name__ == "__main__":
plotter
.
plot
.
zmin
=
0.
plotter
.
plot
.
zmax
=
3.
sm
=
ift
.
SmoothingOperator
.
make
(
plot_space
,
sigma
=
0.03
)
sm
=
ift
.
FFT
SmoothingOperator
(
plot_space
,
sigma
=
0.03
)
plotter
(
ift
.
log
(
ift
.
sqrt
(
sm
(
ift
.
Field
(
plot_space
,
val
=
variance
.
val
.
real
)))),
path
=
'uncertainty.html'
)
plotter
.
plot
.
zmin
=
np
.
real
(
mock_signal
.
min
());
...
...
nifty/operators/response_operator/response_operator.py
View file @
15fc7b6d
...
...
@@ -3,7 +3,7 @@ import numpy as np
from
nifty
import
Field
,
\
FieldArray
from
nifty.operators.linear_operator
import
LinearOperator
from
nifty.operators.smoothing_operator
import
SmoothingOperator
from
nifty.operators.smoothing_operator
import
FFT
SmoothingOperator
from
nifty.operators.composed_operator
import
ComposedOperator
from
nifty.operators.diagonal_operator
import
DiagonalOperator
...
...
@@ -81,7 +81,7 @@ class ResponseOperator(LinearOperator):
"exposure do not match"
)
for
ii
in
range
(
len
(
kernel_smoothing
)):
kernel_smoothing
[
ii
]
=
SmoothingOperator
.
make
(
self
.
_domain
[
ii
],
kernel_smoothing
[
ii
]
=
FFT
SmoothingOperator
(
self
.
_domain
[
ii
],
sigma
=
sigma
[
ii
])
kernel_exposure
[
ii
]
=
DiagonalOperator
(
self
.
_domain
[
ii
],
diagonal
=
exposure
[
ii
])
...
...
nifty/operators/smoothing_operator/__init__.py
View file @
15fc7b6d
...
...
@@ -16,4 +16,5 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
.smoothing_operator
import
SmoothingOperator
from
.fft_smoothing_operator
import
FFTSmoothingOperator
from
.direct_smoothing_operator
import
DirectSmoothingOperator
nifty/operators/smoothing_operator/smoothing_operator.py
View file @
15fc7b6d
...
...
@@ -83,34 +83,6 @@ class SmoothingOperator(EndomorphicOperator):
"""
@
staticmethod
def
make
(
domain
,
sigma
,
log_distances
=
False
,
default_spaces
=
None
):
_fft_smoothing_spaces
=
[
RGSpace
,
GLSpace
,
HPSpace
]
_direct_smoothing_spaces
=
[
PowerSpace
]
domain
=
SmoothingOperator
.
_parse_domain
(
domain
)
if
len
(
domain
)
!=
1
:
raise
ValueError
(
"SmoothingOperator only accepts exactly one "
"space as input domain."
)
if
np
.
any
([
isinstance
(
domain
[
0
],
sp
)
for
sp
in
_fft_smoothing_spaces
]):
from
.fft_smoothing_operator
import
FFTSmoothingOperator
return
FFTSmoothingOperator
(
domain
,
sigma
,
default_spaces
)
elif
np
.
any
([
isinstance
(
domain
[
0
],
sp
)
for
sp
in
_direct_smoothing_spaces
]):
from
.direct_smoothing_operator
import
DirectSmoothingOperator
return
DirectSmoothingOperator
(
domain
,
sigma
,
log_distances
,
\
default_spaces
)
else
:
raise
NotImplementedError
(
"For the given Space smoothing "
" is not available."
)
# ---Overwritten properties and methods---
def
__init__
(
self
,
domain
,
sigma
,
log_distances
=
False
,
default_spaces
=
None
):
...
...
test/test_operators/test_smoothing_operator.py
View file @
15fc7b6d
...
...
@@ -23,7 +23,8 @@ from numpy.testing import assert_equal, assert_allclose
from
nifty
import
Field
,
\
RGSpace
,
\
PowerSpace
,
\
SmoothingOperator
FFTSmoothingOperator
,
\
DirectSmoothingOperator
from
itertools
import
product
from
test.common
import
expand
...
...
@@ -40,7 +41,7 @@ class SmoothingOperator_Tests(unittest.TestCase):
@
expand
(
product
(
spaces
,
[
0.
,
.
5
,
5.
]))
def
test_property
(
self
,
space
,
sigma
):
op
=
SmoothingOperator
.
make
(
space
,
sigma
=
sigma
)
op
=
FFT
SmoothingOperator
(
space
,
sigma
=
sigma
)
if
op
.
domain
[
0
]
!=
space
:
raise
TypeError
if
op
.
unitary
!=
False
:
...
...
@@ -54,7 +55,7 @@ class SmoothingOperator_Tests(unittest.TestCase):
@
expand
(
product
(
spaces
,
[
0.
,
.
5
,
5.
]))
def
test_adjoint_times
(
self
,
space
,
sigma
):
op
=
SmoothingOperator
.
make
(
space
,
sigma
=
sigma
)
op
=
FFT
SmoothingOperator
(
space
,
sigma
=
sigma
)
rand1
=
Field
.
from_random
(
'normal'
,
domain
=
space
)
rand2
=
Field
.
from_random
(
'normal'
,
domain
=
space
)
tt1
=
rand1
.
vdot
(
op
.
times
(
rand2
))
...
...
@@ -63,7 +64,7 @@ class SmoothingOperator_Tests(unittest.TestCase):
@
expand
(
product
(
spaces
,
[
0.
,
.
5
,
5.
]))
def
test_times
(
self
,
space
,
sigma
):
op
=
SmoothingOperator
.
make
(
space
,
sigma
=
sigma
)
op
=
FFT
SmoothingOperator
(
space
,
sigma
=
sigma
)
rand1
=
Field
(
space
,
val
=
0.
)
rand1
.
val
[
0
]
=
1.
tt1
=
op
.
times
(
rand1
)
...
...
@@ -74,7 +75,7 @@ class SmoothingOperator_Tests(unittest.TestCase):
def
test_smooth_regular1
(
self
,
sz
,
d
,
sigma
,
tp
):
tol
=
_get_rtol
(
tp
)
sp
=
RGSpace
(
sz
,
harmonic
=
True
,
distances
=
d
)
smo
=
SmoothingOperator
.
make
(
sp
,
sigma
=
sigma
)
smo
=
FFT
SmoothingOperator
(
sp
,
sigma
=
sigma
)
inp
=
Field
.
from_random
(
domain
=
sp
,
random_type
=
'normal'
,
std
=
1
,
mean
=
4
,
dtype
=
tp
)
out
=
smo
(
inp
)
...
...
@@ -86,7 +87,7 @@ class SmoothingOperator_Tests(unittest.TestCase):
def
test_smooth_regular2
(
self
,
sz1
,
sz2
,
d1
,
d2
,
sigma
,
tp
):
tol
=
_get_rtol
(
tp
)
sp
=
RGSpace
([
sz1
,
sz2
],
distances
=
[
d1
,
d2
],
harmonic
=
True
)
smo
=
SmoothingOperator
.
make
(
sp
,
sigma
=
sigma
)
smo
=
FFT
SmoothingOperator
(
sp
,
sigma
=
sigma
)
inp
=
Field
.
from_random
(
domain
=
sp
,
random_type
=
'normal'
,
std
=
1
,
mean
=
4
,
dtype
=
tp
)
out
=
smo
(
inp
)
...
...
@@ -99,7 +100,7 @@ class SmoothingOperator_Tests(unittest.TestCase):
tol
=
_get_rtol
(
tp
)
sp
=
RGSpace
(
sz
,
harmonic
=
True
)
ps
=
PowerSpace
(
sp
,
nbin
=
sz
,
logarithmic
=
log
)
smo
=
SmoothingOperator
.
make
(
ps
,
sigma
=
sigma
)
smo
=
Direct
SmoothingOperator
(
ps
,
sigma
=
sigma
)
inp
=
Field
.
from_random
(
domain
=
ps
,
random_type
=
'normal'
,
std
=
1
,
mean
=
4
,
dtype
=
tp
)
out
=
smo
(
inp
)
...
...
@@ -112,7 +113,7 @@ class SmoothingOperator_Tests(unittest.TestCase):
tol
=
_get_rtol
(
tp
)
sp
=
RGSpace
([
sz1
,
sz2
],
harmonic
=
True
)
ps
=
PowerSpace
(
sp
,
logarithmic
=
log
)
smo
=
SmoothingOperator
.
make
(
ps
,
sigma
=
sigma
)
smo
=
Direct
SmoothingOperator
(
ps
,
sigma
=
sigma
)
inp
=
Field
.
from_random
(
domain
=
ps
,
random_type
=
'normal'
,
std
=
1
,
mean
=
4
,
dtype
=
tp
)
out
=
smo
(
inp
)
...
...
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