From 7f18a1ccdfc55fb0a48f2fd0a7d8522abe9111cf Mon Sep 17 00:00:00 2001
From: Theo Steininger <theo.steininger@ultimanet.de>
Date: Wed, 21 Jun 2017 10:01:09 +0200
Subject: [PATCH] Removed trace_log and determinat methods from diagonal
 operator.

---
 nifty/minimization/conjugate_gradient.py      |   2 +-
 .../diagonal_operator/diagonal_operator.py    | 121 ------------------
 .../response_operator/response_operator.py    |   2 +-
 test/test_operators/test_diagonal_operator.py |  58 ---------
 4 files changed, 2 insertions(+), 181 deletions(-)

diff --git a/nifty/minimization/conjugate_gradient.py b/nifty/minimization/conjugate_gradient.py
index 00a12efa9..d7caccdd0 100644
--- a/nifty/minimization/conjugate_gradient.py
+++ b/nifty/minimization/conjugate_gradient.py
@@ -70,7 +70,7 @@ class ConjugateGradient(Loggable, object):
 
     References
     ----------
-    Thomas V. Mikosch et al., "Numerical Optimization", Second Edition,
+    Jorge Nocedal & Stephen Wright, "Numerical Optimization", Second Edition,
     2006, Springer-Verlag New York
 
     """
diff --git a/nifty/operators/diagonal_operator/diagonal_operator.py b/nifty/operators/diagonal_operator/diagonal_operator.py
index 77f843fc2..f45cac9cb 100644
--- a/nifty/operators/diagonal_operator/diagonal_operator.py
+++ b/nifty/operators/diagonal_operator/diagonal_operator.py
@@ -132,127 +132,6 @@ class DiagonalOperator(EndomorphicOperator):
         return self._times_helper(x, spaces,
                                   operation=lambda z: z.adjoint().__rdiv__)
 
-    def diagonal(self, bare=False, copy=True):
-        """ Returns the diagonal of the Operator.
-
-        Parameters
-        ----------
-        bare : boolean
-            Whether the returned Field values should be bare or not.
-        copy : boolean
-            Whether the returned Field should be copied or not.
-
-        Returns
-        -------
-        out : Field
-            The diagonal of the Operator.
-
-        """
-        if bare:
-            diagonal = self._diagonal.weight(power=-1)
-        elif copy:
-            diagonal = self._diagonal.copy()
-        else:
-            diagonal = self._diagonal
-        return diagonal
-
-    def inverse_diagonal(self, bare=False):
-        """ Returns the inverse-diagonal of the operator.
-
-        Parameters
-        ----------
-        bare : boolean
-            Whether the returned Field values should be bare or not.
-
-        Returns
-        -------
-        out : Field
-            The inverse of the diagonal of the Operator.
-
-        """        
-        return 1./self.diagonal(bare=bare, copy=False)
-
-    def trace(self, bare=False):
-        """ Returns the trace the operator.
-
-        Parameters
-        ----------
-        bare : boolean
-            Whether the returned Field values should be bare or not.
-
-        Returns
-        -------
-        out : scalar
-            The trace of the Operator.
-
-        """
-        return self.diagonal(bare=bare, copy=False).sum()
-
-    def inverse_trace(self, bare=False):
-        """ Returns the inverse-trace of the operator.
-
-        Parameters
-        ----------
-        bare : boolean
-            Whether the returned Field values should be bare or not.
-
-        Returns
-        -------
-        out : scalar
-            The inverse of the trace of the Operator.
-
-        """
-        return self.inverse_diagonal(bare=bare).sum()
-
-    def trace_log(self):
-        """ Returns the trave-log of the operator.
-
-        Returns
-        -------
-        out : scalar
-            the trace of the logarithm of the Operator.
-
-        """
-        log_diagonal = nifty_log(self.diagonal(copy=False))
-        return log_diagonal.sum()
-
-    def determinant(self):
-        """ Returns the determinant of the operator.
-
-        Returns
-        -------
-        out : scalar
-        out : scalar
-            the determinant of the Operator
-
-        """
-
-        return self.diagonal(copy=False).val.prod()
-
-    def inverse_determinant(self):
-        """ Returns the inverse-determinant of the operator.
-
-        Returns
-        -------
-        out : scalar
-            the inverse-determinant of the Operator
-
-        """
-
-        return 1/self.determinant()
-
-    def log_determinant(self):
-        """ Returns the log-eterminant of the operator.
-
-        Returns
-        -------
-        out : scalar
-            the log-determinant of the Operator
-
-        """
-
-        return np.log(self.determinant())
-
     # ---Mandatory properties and methods---
 
     @property
diff --git a/nifty/operators/response_operator/response_operator.py b/nifty/operators/response_operator/response_operator.py
index 0e25e4282..75361469d 100644
--- a/nifty/operators/response_operator/response_operator.py
+++ b/nifty/operators/response_operator/response_operator.py
@@ -85,7 +85,7 @@ class ResponseOperator(LinearOperator):
         kernel_smoothing = len(self._domain)*[None]
         kernel_exposure = len(self._domain)*[None]
 
-        if len(sigma)!= len(exposure):
+        if len(sigma) != len(exposure):
             raise ValueError("Length of smoothing kernel and length of"
                              "exposure do not match")
 
diff --git a/test/test_operators/test_diagonal_operator.py b/test/test_operators/test_diagonal_operator.py
index ef953fa06..9b8bf86ce 100644
--- a/test/test_operators/test_diagonal_operator.py
+++ b/test/test_operators/test_diagonal_operator.py
@@ -76,61 +76,3 @@ class DiagonalOperator_Tests(unittest.TestCase):
         D = DiagonalOperator(space, diagonal=diag, bare=bare, copy=copy)
         tt = D.adjoint_inverse_times(rand1)
         assert_equal(tt.domain[0], space)
-
-    @expand(product(spaces, [True, False]))
-    def test_diagonal(self, space, copy):
-        diag = Field.from_random('normal', domain=space)
-        D = DiagonalOperator(space, diagonal=diag, copy=copy)
-        diag_op = D.diagonal()
-        assert_allclose(diag.val.get_full_data(), diag_op.val.get_full_data())
-
-    @expand(product(spaces, [True, False]))
-    def test_inverse(self, space, copy):
-        diag = Field.from_random('normal', domain=space)
-        D = DiagonalOperator(space, diagonal=diag, copy=copy)
-        diag_op = D.inverse_diagonal()
-        assert_allclose(1./diag.val.get_full_data(), diag_op.val.get_full_data())
-
-    @expand(product(spaces, [True, False]))
-    def test_trace(self, space, copy):
-        diag = Field.from_random('normal', domain=space)
-        D = DiagonalOperator(space, diagonal=diag, copy=copy)
-        trace_op = D.trace()
-        assert_allclose(trace_op, np.sum(diag.val.get_full_data()))
-
-    @expand(product(spaces, [True, False]))
-    def test_inverse_trace(self, space, copy):
-        diag = Field.from_random('normal', domain=space)
-        D = DiagonalOperator(space, diagonal=diag, copy=copy)
-        trace_op = D.inverse_trace()
-        assert_allclose(trace_op, np.sum(1./diag.val.get_full_data()))
-
-    @expand(product(spaces, [True, False]))
-    #MR FIXME: what if any diagonal element <=0?
-    def test_trace_log(self, space, copy):
-        diag = Field.from_random('normal', domain=space)
-        D = DiagonalOperator(space, diagonal=diag, copy=copy)
-        trace_log = D.trace_log()
-        assert_allclose(trace_log, np.sum(np.log(diag.val.get_full_data())))
-
-    @expand(product(spaces, [True, False]))
-    def test_determinant(self, space, copy):
-        diag = Field.from_random('normal', domain=space)
-        D = DiagonalOperator(space, diagonal=diag, copy=copy)
-        det = D.determinant()
-        assert_allclose(det, np.prod(diag.val.get_full_data()))
-
-    @expand(product(spaces, [True, False], [True, False]))
-    def test_inverse_determinant(self, space, bare, copy):
-        diag = Field.from_random('normal', domain=space)
-        D = DiagonalOperator(space, diagonal=diag, bare=bare, copy=copy)
-        inv_det = D.inverse_determinant()
-        assert_allclose(inv_det, 1./D.determinant())
-
-    @expand(product(spaces, [True, False], [True, False]))
-    #MR FIXME: what if determinant <=0?
-    def test_log_determinant(self, space, bare, copy):
-        diag = Field.from_random('normal', domain=space)
-        D = DiagonalOperator(space, diagonal=diag, bare=bare, copy=copy)
-        log_det = D.log_determinant()
-        assert_allclose(log_det, np.log(D.determinant()))
-- 
GitLab