From 6f6c284d61b8bd6e5129203bb3cd7f6cb6fb52dc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:24:24 +0000 Subject: [PATCH] [pre-commit.ci] Automatic python formatting --- spyrit/core/meas.py | 16 ++++++++-------- spyrit/core/torch.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spyrit/core/meas.py b/spyrit/core/meas.py index 8d33ff11..c8bab46a 100644 --- a/spyrit/core/meas.py +++ b/spyrit/core/meas.py @@ -316,18 +316,18 @@ def _set_P(self, H_static: torch.tensor) -> None: torch.cat([H_pos, H_neg], 1).view(2 * H_static.shape[0], H_static.shape[1]), requires_grad=False, ) - - def _build_pinv(self, tensor: torch.tensor, reg: str, eta: float - ) -> torch.tensor: - + + def _build_pinv(self, tensor: torch.tensor, reg: str, eta: float) -> torch.tensor: + if reg == "L1": pinv = torch.linalg.pinv(tensor, atol=eta) elif reg == "L2": if tensor.shape[0] >= tensor.shape[1]: pinv = ( - torch.linalg.inv(tensor.T @ tensor - + eta * torch.eye(tensor.shape[1])) + torch.linalg.inv( + tensor.T @ tensor + eta * torch.eye(tensor.shape[1]) + ) @ tensor.T ) else: @@ -347,7 +347,7 @@ def _build_pinv(self, tensor: torch.tensor, reg: str, eta: float + "choose either 'L1', 'L2' or 'H1'." ) return pinv - + def _attributeslist(self) -> list: _list = [ ("M", "self.M", _Base), @@ -507,7 +507,7 @@ def get_H(self) -> torch.tensor: ) return self.H - def build_H_pinv(self, reg: str = 'L1', eta: float = 1e-3) -> None: + def build_H_pinv(self, reg: str = "L1", eta: float = 1e-3) -> None: """Used to set the pseudo inverse of the measurement matrix :math:`H` using `torch.linalg.pinv`. The result is stored in the attribute :attr:`H_pinv`. diff --git a/spyrit/core/torch.py b/spyrit/core/torch.py index f9d2a053..76901347 100644 --- a/spyrit/core/torch.py +++ b/spyrit/core/torch.py @@ -239,7 +239,7 @@ def neumann_boundary(img_shape): Returns: :class:`torch.tensor`: The finite difference matrix. - + .. note:: This function returns the same matrix as :func:`finite_diff_mat` with the Neumann boundary condition. Internal implementation is different