Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__repr__ for operators #533

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/mrpro/operators/FastFourierOp.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,8 @@ def adjoint(self, y: torch.Tensor) -> tuple[torch.Tensor,]:
dim=self._dim,
),
)

def __repr__(self):
"""Representation method for FastFourierOperator."""
out = f'Dimension along which FFT/NUFFT is applied: {self._dim!s} \n'
return out
16 changes: 16 additions & 0 deletions src/mrpro/operators/FourierOp.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def get_traj(traj: KTrajectory, dims: Sequence[int]):
self._fwd_nufft_op = None
self._adj_nufft_op = None
self._kshape = traj.broadcasted_shape
self._traj = traj

@classmethod
def from_kdata(cls, kdata: KData, recon_shape: SpatialDimension[int] | None = None) -> Self:
Expand Down Expand Up @@ -223,3 +224,18 @@ def adjoint(self, x: torch.Tensor) -> tuple[torch.Tensor,]:
x = x.permute(*unpermute)

return (x,)

def __repr__(self):
"""Representation method for Fourier Operator."""
device = str(self._traj.device)
if self._nufft_dims:
dims = self._nufft_dims
else:
dims = self._fft_dims
Stef-Martin marked this conversation as resolved.
Show resolved Hide resolved
out = (
f'{type(self).__name__} on device: {device}\n'
f'{self._traj}\n'
f'Dimension along which FFT/NUFFT is applied: {dims}\n'
f'Dimension which is ignored in FFT/NUFFT: {self._ignore_dims}\n'
)
return out