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

minor tweaks

parent 7c821ad1
......@@ -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,7 +195,7 @@ 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 "
print("WARNING: Field has a space in `domain` which is "
"neither harmonic nor a PowerSpace.")
# check if the `spaces` input is valid
......
......@@ -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:
......
......@@ -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):
"""
......
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