Commit 1297585d authored by Theo Steininger's avatar Theo Steininger
Browse files

Merge branch 'python3' into 'master'

Add Python3 compatibility

See merge request !156
parents da29a8f4 a476b875
Pipeline #17025 passed with stages
in 24 minutes and 49 seconds
......@@ -18,14 +18,14 @@
import numpy as np
import nifty.nifty_utilities as utilities
from nifty.spaces import RGSpace,\
GLSpace,\
HPSpace,\
LMSpace
from nifty.operators.linear_operator import LinearOperator
from transformations import RGRGTransformation,\
from ... import nifty_utilities as utilities
from ...spaces import RGSpace,\
GLSpace,\
HPSpace,\
LMSpace
from ..linear_operator import LinearOperator
from .transformations import RGRGTransformation,\
LMGLTransformation,\
LMHPTransformation,\
GLLMTransformation,\
......
......@@ -16,10 +16,10 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from rgrgtransformation import RGRGTransformation
from gllmtransformation import GLLMTransformation
from hplmtransformation import HPLMTransformation
from lmgltransformation import LMGLTransformation
from lmhptransformation import LMHPTransformation
from .rgrgtransformation import RGRGTransformation
from .gllmtransformation import GLLMTransformation
from .hplmtransformation import HPLMTransformation
from .lmgltransformation import LMGLTransformation
from .lmhptransformation import LMHPTransformation
from transformation_cache import TransformationCache
\ No newline at end of file
from .transformation_cache import TransformationCache
......@@ -18,10 +18,10 @@
import numpy as np
from nifty.config import dependency_injector as gdi
from nifty import GLSpace, LMSpace
from slicing_transformation import SlicingTransformation
import lm_transformation_helper
from ....config import dependency_injector as gdi
from .... import GLSpace, LMSpace
from .slicing_transformation import SlicingTransformation
from . import lm_transformation_helper
pyHealpix = gdi.get('pyHealpix')
......
......@@ -18,11 +18,11 @@
import numpy as np
from nifty.config import dependency_injector as gdi
from nifty import HPSpace, LMSpace
from slicing_transformation import SlicingTransformation
from ....config import dependency_injector as gdi
from .... import HPSpace, LMSpace
from .slicing_transformation import SlicingTransformation
import lm_transformation_helper
from . import lm_transformation_helper
pyHealpix = gdi.get('pyHealpix')
......
from __future__ import division
import numpy as np
def buildLm(nr, lmax):
new_dtype = np.result_type(nr.dtype, np.complex64)
size = (len(nr)-lmax-1)/2+lmax+1
size = (len(nr)-lmax-1)//2+lmax+1
res = np.zeros([size], dtype=new_dtype)
res[0:lmax+1] = nr[0:lmax+1]
res[lmax+1:] = np.sqrt(0.5)*(nr[lmax+1::2] + 1j*nr[lmax+2::2])
......
......@@ -17,11 +17,11 @@
# and financially supported by the Studienstiftung des deutschen Volkes.
import numpy as np
from nifty.config import dependency_injector as gdi
from nifty import GLSpace, LMSpace
from ....config import dependency_injector as gdi
from .... import GLSpace, LMSpace
from slicing_transformation import SlicingTransformation
import lm_transformation_helper
from .slicing_transformation import SlicingTransformation
from . import lm_transformation_helper
pyHealpix = gdi.get('pyHealpix')
......
......@@ -17,10 +17,10 @@
# and financially supported by the Studienstiftung des deutschen Volkes.
import numpy as np
from nifty.config import dependency_injector as gdi
from nifty import HPSpace, LMSpace
from slicing_transformation import SlicingTransformation
import lm_transformation_helper
from ....config import dependency_injector as gdi
from .... import HPSpace, LMSpace
from .slicing_transformation import SlicingTransformation
from . import lm_transformation_helper
pyHealpix = gdi.get('pyHealpix')
......
......@@ -16,14 +16,17 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from builtins import range
from builtins import object
import warnings
import numpy as np
from d2o import distributed_data_object, STRATEGIES
from nifty.config import dependency_injector as gdi
import nifty.nifty_utilities as utilities
from ....config import dependency_injector as gdi
from .... import nifty_utilities as utilities
from keepers import Loggable
from functools import reduce
fftw = gdi.get('fftw')
......
......@@ -16,10 +16,11 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from __future__ import division
import numpy as np
from transformation import Transformation
from rg_transforms import MPIFFT, SerialFFT
from nifty import RGSpace, nifty_configuration
from .transformation import Transformation
from .rg_transforms import MPIFFT, SerialFFT
from .... import RGSpace, nifty_configuration
class RGRGTransformation(Transformation):
......@@ -84,8 +85,8 @@ class RGRGTransformation(Transformation):
zerocenter = temp
# calculate the initialization parameters
distances = 1 / (np.array(domain.shape) *
np.array(domain.distances))
distances = 1. / (np.array(domain.shape) *
np.array(domain.distances))
new_space = RGSpace(domain.shape,
zerocenter=zerocenter,
......
......@@ -19,8 +19,8 @@
import abc
import numpy as np
import nifty.nifty_utilities as utilities
from transformation import Transformation
from .... import nifty_utilities as utilities
from .transformation import Transformation
class SlicingTransformation(Transformation):
......
......@@ -19,14 +19,14 @@
import abc
from keepers import Loggable
from future.utils import with_metaclass
class Transformation(Loggable, object):
class Transformation(with_metaclass(abc.ABCMeta, type('NewBase', (Loggable, object), {}))):
"""
A generic transformation which defines a static check_codomain
method for all transforms.
"""
__metaclass__ = abc.ABCMeta
def __init__(self, domain, codomain, module=None):
if codomain is None:
......
......@@ -16,6 +16,7 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from builtins import object
class _TransformationCache(object):
def __init__(self):
......
......@@ -16,4 +16,4 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from invertible_operator_mixin import InvertibleOperatorMixin
\ No newline at end of file
from .invertible_operator_mixin import InvertibleOperatorMixin
......@@ -16,6 +16,7 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from builtins import object
from nifty.minimization import ConjugateGradient
from nifty.field import Field
......
# -*- coding: utf-8 -*-
from laplace_operator import LaplaceOperator
from .laplace_operator import LaplaceOperator
......@@ -16,4 +16,4 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from linear_operator import LinearOperator
from .linear_operator import LinearOperator
......@@ -16,15 +16,17 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from builtins import str
import abc
from nifty.nifty_meta import NiftyMeta
from keepers import Loggable
from nifty.field import Field
import nifty.nifty_utilities as utilities
from future.utils import with_metaclass
class LinearOperator(Loggable, object):
class LinearOperator(with_metaclass(NiftyMeta, type('NewBase', (Loggable, object), {}))):
"""NIFTY base class for linear operators.
The base NIFTY operator class is an abstract class from which
......@@ -70,8 +72,6 @@ class LinearOperator(Loggable, object):
"""
__metaclass__ = NiftyMeta
def __init__(self, default_spaces=None):
self._default_spaces = default_spaces
......
......@@ -16,4 +16,4 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from projection_operator import ProjectionOperator
from .projection_operator import ProjectionOperator
......@@ -16,6 +16,7 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from builtins import range
import numpy as np
from nifty.field import Field
......@@ -99,7 +100,7 @@ class ProjectionOperator(EndomorphicOperator):
# the one of x, reshape the local data of self and apply it directly
active_axes = []
if spaces is None:
active_axes = range(len(x.shape))
active_axes = list(range(len(x.shape)))
else:
for space_index in spaces:
active_axes += x.domain_axes[space_index]
......@@ -124,10 +125,10 @@ class ProjectionOperator(EndomorphicOperator):
local_x = x.val.get_local_data(copy=False)
l = len(local_projection_vector.shape)
sublist_projector = range(l)
sublist_projector = list(range(l))
sublist_x = np.arange(len(local_x.shape)) + l
for i in xrange(l):
for i in range(l):
a = active_axes[i]
sublist_x[a] = i
......
from response_operator import ResponseOperator
from .response_operator import ResponseOperator
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