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
3e991a41
Commit
3e991a41
authored
Aug 18, 2017
by
Martin Reinecke
Browse files
remove inverse smoothing code, since it was broken and unused
parent
fa9303d5
Pipeline
#16828
passed with stage
in 14 minutes and 6 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty/operators/smoothing_operator/direct_smoothing_operator.py
View file @
3e991a41
...
...
@@ -132,7 +132,7 @@ class DirectSmoothingOperator(SmoothingOperator):
return
outarr
def
_smooth
(
self
,
x
,
spaces
,
inverse
):
def
_smooth
(
self
,
x
,
spaces
):
# infer affected axes
# we rely on the knowledge, that `spaces` is a tuple with length 1.
affected_axes
=
x
.
domain_axes
[
spaces
[
0
]]
...
...
@@ -203,18 +203,13 @@ class DirectSmoothingOperator(SmoothingOperator):
# currently only one axis is supported
data_axis
=
affected_axes
[
0
]
if
inverse
:
true_sigma
=
1.
/
self
.
sigma
else
:
true_sigma
=
self
.
sigma
local_result
=
self
.
_apply_along_axis
(
data_axis
,
augmented_data
,
startindex
=
true_start
,
endindex
=
true_end
,
distances
=
augmented_distance_array
,
smooth_length
=
true_
sigma
,
smooth_length
=
self
.
sigma
,
smoothing_width
=
self
.
effective_smoothing_width
)
result
=
x
.
copy_empty
()
...
...
nifty/operators/smoothing_operator/fft_smoothing_operator.py
View file @
3e991a41
...
...
@@ -17,7 +17,7 @@ class FFTSmoothingOperator(SmoothingOperator):
default_spaces
=
default_spaces
)
self
.
_transformator_cache
=
{}
def
_smooth
(
self
,
x
,
spaces
,
inverse
):
def
_smooth
(
self
,
x
,
spaces
):
# transform to the (global-)default codomain and perform all remaining
# steps therein
transformator
=
self
.
_get_transformator
(
x
.
dtype
)
...
...
@@ -46,13 +46,7 @@ class FFTSmoothingOperator(SmoothingOperator):
for
i
in
xrange
(
len
(
transformed_x
.
shape
))]
local_kernel
=
np
.
reshape
(
local_kernel
,
reshaper
)
# apply the kernel
if
inverse
:
# avoid zeroes in the kernel to work around divisions by zero
local_kernel
=
np
.
maximum
(
1e-12
,
local_kernel
)
local_transformed_x
/=
local_kernel
else
:
local_transformed_x
*=
local_kernel
local_transformed_x
*=
local_kernel
transformed_x
.
val
.
set_local_data
(
local_transformed_x
,
copy
=
False
)
...
...
nifty/operators/smoothing_operator/smoothing_operator.py
View file @
3e991a41
...
...
@@ -138,19 +138,6 @@ class SmoothingOperator(EndomorphicOperator):
self
.
_sigma
=
sigma
self
.
_log_distances
=
log_distances
def
_inverse_times
(
self
,
x
,
spaces
):
if
self
.
sigma
==
0
:
return
x
.
copy
()
# the domain of the smoothing operator contains exactly one space.
# Hence, if spaces is None, but we passed LinearOperator's
# _check_input_compatibility, we know that x is also solely defined
# on that space
if
spaces
is
None
:
spaces
=
(
0
,)
return
self
.
_smooth
(
x
,
spaces
,
inverse
=
True
)
def
_times
(
self
,
x
,
spaces
):
if
self
.
sigma
==
0
:
return
x
.
copy
()
...
...
@@ -162,7 +149,7 @@ class SmoothingOperator(EndomorphicOperator):
if
spaces
is
None
:
spaces
=
(
0
,)
return
self
.
_smooth
(
x
,
spaces
,
inverse
=
False
)
return
self
.
_smooth
(
x
,
spaces
)
# ---Mandatory properties and methods---
@
property
...
...
@@ -188,5 +175,5 @@ class SmoothingOperator(EndomorphicOperator):
return
self
.
_log_distances
@
abc
.
abstractmethod
def
_smooth
(
self
,
x
,
spaces
,
inverse
):
def
_smooth
(
self
,
x
,
spaces
):
raise
NotImplementedError
test/test_operators/test_smoothing_operator.py
View file @
3e991a41
...
...
@@ -69,15 +69,6 @@ class SmoothingOperator_Tests(unittest.TestCase):
tt1
=
op
.
times
(
rand1
)
assert_allclose
(
1
,
tt1
.
sum
())
@
expand
(
product
(
spaces
,
[
0.
,
.
5
,
5.
]))
def
test_inverse_adjoint_times
(
self
,
space
,
sigma
):
op
=
SmoothingOperator
(
space
,
sigma
=
sigma
)
rand1
=
Field
.
from_random
(
'normal'
,
domain
=
space
)
rand2
=
Field
.
from_random
(
'normal'
,
domain
=
space
)
tt1
=
rand1
.
vdot
(
op
.
inverse_times
(
rand2
))
tt2
=
rand2
.
vdot
(
op
.
inverse_adjoint_times
(
rand1
))
assert_allclose
(
tt1
,
tt2
)
@
expand
(
product
([
128
,
256
],
[
1
,
0.4
],
[
0.
,
1.
,
3.7
],
[
np
.
float64
,
np
.
complex128
]))
def
test_smooth_regular1
(
self
,
sz
,
d
,
sigma
,
tp
):
...
...
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