Commit 1d0e22b7 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

minor tweaks

parent 7c821ad1
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes. # and financially supported by the Studienstiftung des deutschen Volkes.
from __future__ import division from __future__ import division, print_function
from builtins import range from builtins import range
import numpy as np import numpy as np
from .spaces.power_space import PowerSpace from .spaces.power_space import PowerSpace
...@@ -195,8 +195,8 @@ class Field(object): ...@@ -195,8 +195,8 @@ class Field(object):
# power_space instances # power_space instances
for sp in self.domain: for sp in self.domain:
if not sp.harmonic and not isinstance(sp, PowerSpace): if not sp.harmonic and not isinstance(sp, PowerSpace):
raise TypeError("Field has a space in `domain` which is " print("WARNING: Field has a space in `domain` which is "
"neither harmonic nor a PowerSpace.") "neither harmonic nor a PowerSpace.")
# check if the `spaces` input is valid # check if the `spaces` input is valid
if spaces is None: if spaces is None:
......
...@@ -48,7 +48,7 @@ def get_slice_list(shape, axes): ...@@ -48,7 +48,7 @@ def get_slice_list(shape, axes):
If axes(axis) does not match shape. If axes(axis) does not match shape.
""" """
if not shape: if shape is None:
raise ValueError("shape cannot be None.") raise ValueError("shape cannot be None.")
if axes: if axes:
......
...@@ -60,6 +60,17 @@ class RGRGTransformation(Transformation): ...@@ -60,6 +60,17 @@ class RGRGTransformation(Transformation):
axes2 = axes[:i] + axes[i+1:] axes2 = axes[:i] + axes[i+1:]
RGRGTransformation._fill_upper_half(tmp[dim1], res[dim1], axes2) 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 @staticmethod
def _hartley(a, axes=None): def _hartley(a, axes=None):
# Check if the axes provided are valid given the shape # Check if the axes provided are valid given the shape
...@@ -71,15 +82,7 @@ class RGRGTransformation(Transformation): ...@@ -71,15 +82,7 @@ class RGRGTransformation(Transformation):
if issubclass(a.dtype.type, np.complexfloating): if issubclass(a.dtype.type, np.complexfloating):
raise TypeError("Hartley tansform requires real-valued arrays.") raise TypeError("Hartley tansform requires real-valued arrays.")
tmp = rfftn(a, axes=axes) tmp = rfftn(a, axes=axes)
res = np.empty_like(a) return RGRGTransformation._fill_array(tmp, np.empty_like(a), 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
def transform(self, val, axes=None): def transform(self, val, axes=None):
""" """
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment