diff --git a/nifty/operators/smoothing_operator/direct_smoothing_operator.py b/nifty/operators/smoothing_operator/direct_smoothing_operator.py index fe4ad0d9660a815f54167a1e061ff709d8a87224..cca3a0a0220bfe3ba86ddedcde2049fdd94ea5aa 100644 --- a/nifty/operators/smoothing_operator/direct_smoothing_operator.py +++ b/nifty/operators/smoothing_operator/direct_smoothing_operator.py @@ -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() diff --git a/nifty/operators/smoothing_operator/fft_smoothing_operator.py b/nifty/operators/smoothing_operator/fft_smoothing_operator.py index 3b4c15bafb47b9923eccb88bfa9bdd9a3c206314..ebe7211014ae9d3d93872715ce90431398bfbe9f 100644 --- a/nifty/operators/smoothing_operator/fft_smoothing_operator.py +++ b/nifty/operators/smoothing_operator/fft_smoothing_operator.py @@ -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) diff --git a/nifty/operators/smoothing_operator/smoothing_operator.py b/nifty/operators/smoothing_operator/smoothing_operator.py index 63843630e5aca298093263d4716ebcd538167624..dab542cfb8618e179c1cf557851994cd507b0594 100644 --- a/nifty/operators/smoothing_operator/smoothing_operator.py +++ b/nifty/operators/smoothing_operator/smoothing_operator.py @@ -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 diff --git a/test/test_operators/test_smoothing_operator.py b/test/test_operators/test_smoothing_operator.py index 3f830e5a9432dd49c441376acd07c28c25733fff..99e86a7953d35dd6dcdf945f0942de30bcc69e3c 100644 --- a/test/test_operators/test_smoothing_operator.py +++ b/test/test_operators/test_smoothing_operator.py @@ -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):