diff --git a/pyproject.toml b/pyproject.toml index c798b6b..49124db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "pyNFFT3" -version = "1.0.1" +version = "1.0.2" authors = [ { name="Michael Nolander", email="nolander.michael@gmail.com" }, ] diff --git a/src/pyNFFT3/FSFT.py b/src/pyNFFT3/FSFT.py index e14ae93..251e362 100644 --- a/src/pyNFFT3/FSFT.py +++ b/src/pyNFFT3/FSFT.py @@ -62,8 +62,8 @@ def __init__( self.init_done = False # bool for plan init self.finalized = False # bool for finalizer # self.x = None # nodes, will be set later - self.f = None # function coefficients - self.fhat = None # spherical Fourier coefficients + self._f = None # function coefficients + self._fhat = None # spherical Fourier coefficients if N <= 0: raise ValueError(f"Invalid N: {N}. Argument must be a positive integer") @@ -197,11 +197,11 @@ def fsft_trafo(self): if self.finalized: raise RuntimeError("FSFT already finalized") - if not hasattr(self, "fhat"): + if not hasattr(self, "_fhat"): raise ValueError("fhat has not been set.") - self.f = np.ctypeslib.as_array( + self._f = np.ctypeslib.as_array( _nfsftlib.jnfsft_trafo(self.plan), shape=(self.M * 2,) - ).view(np.complex128) + ).view(np.complex128).copy() def trafo(self): """ @@ -217,11 +217,11 @@ def fsft_trafo_direct(self): if self.finalized: raise RuntimeError("FSFT already finalized") - if self.fhat is None: + if self._fhat is None: raise ValueError("fhat has not been set.") - self.f = np.ctypeslib.as_array( + self._f = np.ctypeslib.as_array( _nfsftlib.jnfsft_trafo_direct(self.plan), shape=(self.M * 2,) - ).view(np.complex128) + ).view(np.complex128).copy() def trafo_direct(self): """ @@ -238,11 +238,11 @@ def fsft_adjoint(self): if self.finalized: raise RuntimeError("FSFT already finalized") - if not hasattr(self, "f"): + if not hasattr(self, "_f"): raise ValueError("f has not been set.") - self.fhat = np.ctypeslib.as_array( + self._fhat = np.ctypeslib.as_array( _nfsftlib.jnfsft_adjoint(self.plan), shape=(N_total * 2,) - ).view(np.complex128) + ).view(np.complex128).copy() def adjoint(self): """ @@ -259,11 +259,11 @@ def fsft_adjoint_direct(self): if self.finalized: raise RuntimeError("FSFT already finalized") - if not hasattr(self, "f"): + if not hasattr(self, "_f"): raise ValueError("f has not been set.") - self.fhat = np.ctypeslib.as_array( + self._fhat = np.ctypeslib.as_array( _nfsftlib.jnfsft_adjoint_direct(self.plan), shape=(N_total * 2,) - ).view(np.complex128) + ).view(np.complex128).copy() def adjoint_direct(self): """ diff --git a/src/pyNFFT3/NFCT.py b/src/pyNFFT3/NFCT.py index 71d7b58..eaab0bf 100644 --- a/src/pyNFFT3/NFCT.py +++ b/src/pyNFFT3/NFCT.py @@ -103,9 +103,9 @@ def __init__( self.f2 = f2 # FFTW flags self.init_done = False # bool for plan init self.finalized = False # bool for finalizer - self.x = None # nodes, will be set later - self.f = None # function values - self.fhat = None # Fourier coefficients + self._X = None # nodes, will be set later + self._f = None # function values + self._fhat = None # Fourier coefficients def __del__(self): self.finalize_plan() @@ -243,12 +243,12 @@ def nfct_trafo(self): if self.finalized: raise RuntimeError("NFCT already finalized") - if not hasattr(self, "fhat"): + if not hasattr(self, "_fhat"): raise ValueError("fhat has not been set.") - if not hasattr(self, "x"): + if not hasattr(self, "_X"): raise ValueError("x has not been set.") - self.f = np.ctypeslib.as_array(_nfctlib.jnfct_trafo(self.plan), shape=(self.M,)) + self._f = np.ctypeslib.as_array(_nfctlib.jnfct_trafo(self.plan), shape=(self.M,)).copy() def trafo(self): """ @@ -264,14 +264,14 @@ def nfct_trafo_direct(self): if self.finalized: raise RuntimeError("NFCT already finalized") - if self.fhat is None: + if self._fhat is None: raise ValueError("fhat has not been set.") - if self.x is None: + if self._X is None: raise ValueError("x has not been set.") - self.f = np.ctypeslib.as_array( + self._f = np.ctypeslib.as_array( _nfctlib.jnfct_trafo_direct(self.plan), shape=(self.M,) - ) + ).copy() def trafo_direct(self): """ @@ -289,14 +289,14 @@ def nfct_transposed(self): if self.finalized: raise RuntimeError("NFCT already finalized") - if self.f is None: + if self._f is None: raise ValueError("f has not been set.") - if self.x is None: + if self._X is None: raise ValueError("x has not been set.") - self.fhat = np.ctypeslib.as_array( + self._fhat = np.ctypeslib.as_array( _nfctlib.jnfct_adjoint(self.plan), shape=(Ns,) - ) + ).copy() def nfct_transposed_direct(self): """ @@ -307,14 +307,14 @@ def nfct_transposed_direct(self): if self.finalized: raise RuntimeError("NFCT already finalized") - if self.f is None: + if self._f is None: raise ValueError("f has not been set.") - if self.x is None: + if self._X is None: raise ValueError("x has not been set.") - self.fhat = np.ctypeslib.as_array( + self._fhat = np.ctypeslib.as_array( _nfctlib.jnfct_adjoint_direct(self.plan), shape=(Ns,) - ) + ).copy() def nfct_adjoint(self): """ diff --git a/src/pyNFFT3/NFFT.py b/src/pyNFFT3/NFFT.py index c8004e2..134340e 100644 --- a/src/pyNFFT3/NFFT.py +++ b/src/pyNFFT3/NFFT.py @@ -103,9 +103,9 @@ def __init__( self.f2 = f2 # FFTW flags self.init_done = False # bool for plan init self.finalized = False # bool for finalizer - self.x = None # nodes, will be set later - self.f = None # function values - self.fhat = None # Fourier coefficients + self._X = None # nodes, will be set later + self._f = None # function values + self._fhat = None # Fourier coefficients def __del__(self): self.finalize_plan() @@ -252,14 +252,14 @@ def nfft_trafo(self): if self.finalized: raise RuntimeError("NFFT already finalized") - if not hasattr(self, "fhat"): + if not hasattr(self, "_fhat"): raise ValueError("fhat has not been set.") - if not hasattr(self, "x"): + if not hasattr(self, "_X"): raise ValueError("x has not been set.") - self.f = np.ctypeslib.as_array( + self._f = np.ctypeslib.as_array( _nfftlib.jnfft_trafo(self.plan), shape=(self.M * 2,) - ).view(np.complex128) + ).view(np.complex128).copy() def trafo(self): """ @@ -275,15 +275,15 @@ def nfft_trafo_direct(self): if self.finalized: raise RuntimeError("NFFT already finalized") - if self.fhat is None: + if self._fhat is None: raise ValueError("fhat has not been set.") - if self.x is None: + if self._X is None: raise ValueError("x has not been set.") - self.f = np.ctypeslib.as_array( + self._f = np.ctypeslib.as_array( _nfftlib.jnfft_trafo_direct(self.plan), shape=(self.M * 2,) - ).view(np.complex128) + ).view(np.complex128).copy() def trafo_direct(self): """ @@ -300,15 +300,15 @@ def nfft_adjoint(self): if self.finalized: raise RuntimeError("NFFT already finalized") - if not hasattr(self, "f"): + if not hasattr(self, "_f"): raise ValueError("f has not been set.") - if not hasattr(self, "x"): + if not hasattr(self, "_X"): raise ValueError("x has not been set.") - self.fhat = np.ctypeslib.as_array( + self._fhat = np.ctypeslib.as_array( _nfftlib.jnfft_adjoint(self.plan), shape=(Ns * 2,) - ).view(np.complex128) + ).view(np.complex128).copy() def adjoint(self): """ @@ -325,15 +325,15 @@ def nfft_adjoint_direct(self): if self.finalized: raise RuntimeError("NFFT already finalized") - if not hasattr(self, "f"): + if not hasattr(self, "_f"): raise ValueError("f has not been set.") - if not hasattr(self, "x"): + if not hasattr(self, "_X"): raise ValueError("x has not been set.") - self.fhat = np.ctypeslib.as_array( + self._fhat = np.ctypeslib.as_array( _nfftlib.jnfft_adjoint_direct(self.plan), shape=(Ns * 2,) - ).view(np.complex128) + ).view(np.complex128).copy() def adjoint_direct(self): """ diff --git a/src/pyNFFT3/NFSFT.py b/src/pyNFFT3/NFSFT.py index 7d4fdcb..1c02d59 100644 --- a/src/pyNFFT3/NFSFT.py +++ b/src/pyNFFT3/NFSFT.py @@ -65,9 +65,9 @@ def __init__( self.nfft_cutoff = nfft_cutoff self.init_done = False # bool for plan init self.finalized = False # bool for finalizer - self.x = None # nodes, will be set later - self.f = None # function coefficients - self.fhat = None # spherical Fourier coefficients + self._X = None # nodes, will be set later + self._f = None # function coefficients + self._fhat = None # spherical Fourier coefficients if N <= 0: raise ValueError(f"Invalid N: {N}. Argument must be a positive integer") @@ -222,14 +222,14 @@ def nfsft_trafo(self): if self.finalized: raise RuntimeError("NFSFT already finalized") - if not hasattr(self, "fhat"): + if not hasattr(self, "_fhat"): raise ValueError("fhat has not been set.") - if not hasattr(self, "x"): + if not hasattr(self, "_X"): raise ValueError("x has not been set.") - self.f = np.ctypeslib.as_array( + self._f = np.ctypeslib.as_array( _nfsftlib.jnfsft_trafo(self.plan), shape=(self.M * 2,) - ).view(np.complex128) + ).view(np.complex128).copy() def trafo(self): """ @@ -245,14 +245,14 @@ def nfsft_trafo_direct(self): if self.finalized: raise RuntimeError("NFSFT already finalized") - if self.fhat is None: + if self._fhat is None: raise ValueError("fhat has not been set.") - if self.x is None: + if self._X is None: raise ValueError("x has not been set.") - self.f = np.ctypeslib.as_array( + self._f = np.ctypeslib.as_array( _nfsftlib.jnfsft_trafo_direct(self.plan), shape=(self.M * 2,) - ).view(np.complex128) + ).view(np.complex128).copy() def trafo_direct(self): """ @@ -269,14 +269,14 @@ def nfsft_adjoint(self): if self.finalized: raise RuntimeError("NFSFT already finalized") - if not hasattr(self, "f"): + if not hasattr(self, "_f"): raise ValueError("f has not been set.") - if not hasattr(self, "x"): + if not hasattr(self, "_X"): raise ValueError("x has not been set.") - self.fhat = np.ctypeslib.as_array( + self._fhat = np.ctypeslib.as_array( _nfsftlib.jnfsft_adjoint(self.plan), shape=(N_total * 2,) - ).view(np.complex128) + ).view(np.complex128).copy() def adjoint(self): """ @@ -293,14 +293,14 @@ def nfsft_adjoint_direct(self): if self.finalized: raise RuntimeError("NFSFT already finalized") - if not hasattr(self, "f"): + if not hasattr(self, "_f"): raise ValueError("f has not been set.") - if not hasattr(self, "x"): + if not hasattr(self, "_X"): raise ValueError("x has not been set.") - self.fhat = np.ctypeslib.as_array( + self._fhat = np.ctypeslib.as_array( _nfsftlib.jnfsft_adjoint_direct(self.plan), shape=(N_total * 2,) - ).view(np.complex128) + ).view(np.complex128).copy() def adjoint_direct(self): """ diff --git a/src/pyNFFT3/NFST.py b/src/pyNFFT3/NFST.py index 5f735ad..5bebd25 100644 --- a/src/pyNFFT3/NFST.py +++ b/src/pyNFFT3/NFST.py @@ -102,9 +102,9 @@ def __init__( self.f2 = f2 # FFTW flags self.init_done = False # bool for plan init self.finalized = False # bool for finalizer - self.x = None # nodes, will be set later - self.f = None # function values - self.fhat = None # Fourier coefficients + self._X = None # nodes, will be set later + self._f = None # function values + self._fhat = None # Fourier coefficients def __del__(self): self.finalize_plan() @@ -242,12 +242,12 @@ def nfst_trafo(self): if self.finalized: raise RuntimeError("NFST already finalized") - if not hasattr(self, "fhat"): + if not hasattr(self, "_fhat"): raise ValueError("fhat has not been set.") - if not hasattr(self, "x"): + if not hasattr(self, "_X"): raise ValueError("x has not been set.") - self.f = np.ctypeslib.as_array(_nfstlib.jnfst_trafo(self.plan), shape=(self.M,)) + self._f = np.ctypeslib.as_array(_nfstlib.jnfst_trafo(self.plan), shape=(self.M,)).copy() def trafo(self): """ @@ -263,14 +263,14 @@ def nfst_trafo_direct(self): if self.finalized: raise RuntimeError("NFST already finalized") - if self.fhat is None: + if self._fhat is None: raise ValueError("fhat has not been set.") - if self.x is None: + if self._X is None: raise ValueError("x has not been set.") - self.f = np.ctypeslib.as_array( + self._f = np.ctypeslib.as_array( _nfstlib.jnfst_trafo_direct(self.plan), shape=(self.M,) - ) + ).copy() def trafo_direct(self): """ @@ -287,14 +287,14 @@ def nfst_transposed(self): if self.finalized: raise RuntimeError("NFST already finalized") - if self.f is None: + if self._f is None: raise ValueError("f has not been set.") - if self.x is None: + if self._X is None: raise ValueError("x has not been set.") - self.fhat = np.ctypeslib.as_array( + self._fhat = np.ctypeslib.as_array( _nfstlib.jnfst_adjoint(self.plan), shape=(Ns,) - ) + ).copy() def nfst_transposed_direct(self): """ @@ -305,14 +305,14 @@ def nfst_transposed_direct(self): if self.finalized: raise RuntimeError("NFST already finalized") - if self.f is None: + if self._f is None: raise ValueError("f has not been set.") - if self.x is None: + if self._X is None: raise ValueError("x has not been set.") - self.fhat = np.ctypeslib.as_array( + self._fhat = np.ctypeslib.as_array( _nfstlib.jnfst_adjoint_direct(self.plan), shape=(Ns,) - ) + ).copy() def nfst_adjoint(self): """ diff --git a/src/pyNFFT3/__init__.py b/src/pyNFFT3/__init__.py index 755a01d..2660e0b 100644 --- a/src/pyNFFT3/__init__.py +++ b/src/pyNFFT3/__init__.py @@ -195,4 +195,4 @@ class fastsum_plan(ctypes.Structure): "default_window_cut_off", "nfsft_default_nfft_cut_off", "nfsft_default_threshold", -] +] \ No newline at end of file