diff --git a/nifty2go/field.py b/nifty2go/field.py index e11352c22a5e1e686c5a52971ee9fdd583a85800..cd118618a307a1be39c2f6f21dfdf4a83167adbf 100644 --- a/nifty2go/field.py +++ b/nifty2go/field.py @@ -16,7 +16,7 @@ # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik # and financially supported by the Studienstiftung des deutschen Volkes. -from __future__ import division +from __future__ import division, print_function from builtins import range import numpy as np from .spaces.power_space import PowerSpace @@ -195,8 +195,8 @@ class Field(object): # power_space instances for sp in self.domain: if not sp.harmonic and not isinstance(sp, PowerSpace): - raise TypeError("Field has a space in `domain` which is " - "neither harmonic nor a PowerSpace.") + print("WARNING: Field has a space in `domain` which is " + "neither harmonic nor a PowerSpace.") # check if the `spaces` input is valid if spaces is None: diff --git a/nifty2go/nifty_utilities.py b/nifty2go/nifty_utilities.py index b072de5d1d86a4f3e70131720c7d8c144fa95206..0b4d5dfcec35fce30bfd0ff83da86a93eaba9502 100644 --- a/nifty2go/nifty_utilities.py +++ b/nifty2go/nifty_utilities.py @@ -48,7 +48,7 @@ def get_slice_list(shape, axes): If axes(axis) does not match shape. """ - if not shape: + if shape is None: raise ValueError("shape cannot be None.") if axes: diff --git a/nifty2go/operators/fft_operator/fft_operator_support.py b/nifty2go/operators/fft_operator/fft_operator_support.py index da734c26ed2041822e6df970fee688288e31fb73..d64f55d8486f5926583b6b776e9400f63c2e53db 100644 --- a/nifty2go/operators/fft_operator/fft_operator_support.py +++ b/nifty2go/operators/fft_operator/fft_operator_support.py @@ -60,6 +60,17 @@ class RGRGTransformation(Transformation): axes2 = axes[:i] + axes[i+1:] RGRGTransformation._fill_upper_half(tmp[dim1], res[dim1], axes2) + @staticmethod + def _fill_array(tmp, res, axes): + if axes is None: + axes = range(a.ndim) + lastaxis = axes[-1] + ntmplast = tmp.shape[lastaxis] + slice1 = [slice(None)]*lastaxis + [slice(0, ntmplast)] + np.add(tmp.real, tmp.imag, out=res[slice1]) + RGRGTransformation._fill_upper_half(tmp, res, axes) + return res + @staticmethod def _hartley(a, axes=None): # Check if the axes provided are valid given the shape @@ -71,15 +82,7 @@ class RGRGTransformation(Transformation): if issubclass(a.dtype.type, np.complexfloating): raise TypeError("Hartley tansform requires real-valued arrays.") tmp = rfftn(a, axes=axes) - res = np.empty_like(a) - if axes is None: - axes = range(a.ndim) - lastaxis = axes[-1] - ntmplast = tmp.shape[lastaxis] - slice1 = [slice(None)]*lastaxis + [slice(0, ntmplast)] - np.add(tmp.real, tmp.imag, out=res[slice1]) - RGRGTransformation._fill_upper_half(tmp, res, axes) - return res + return RGRGTransformation._fill_array(tmp, np.empty_like(a), axes) def transform(self, val, axes=None): """