Commit 3c771b2f authored by Theo Steininger's avatar Theo Steininger
Browse files

Merge branch 'master' of gitlab.mpcdf.mpg.de:ift/NIFTy

parents 9ee541a0 1c1b6377
Pipeline #17228 passed with stages
in 25 minutes and 7 seconds
......@@ -16,9 +16,9 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from nifty.minimization import ConjugateGradient
from nifty.field import Field
from builtins import object
from ...minimization import ConjugateGradient
from ...field import Field
class InvertibleOperatorMixin(object):
......
# -*- coding: utf-8 -*-
from laplace_operator import LaplaceOperator
from .laplace_operator import LaplaceOperator
......@@ -17,11 +17,11 @@
# and financially supported by the Studienstiftung des deutschen Volkes.
import numpy as np
from nifty.field import Field
from nifty.spaces.power_space import PowerSpace
from nifty.operators.endomorphic_operator import EndomorphicOperator
from nifty import sqrt
import nifty.nifty_utilities as utilities
from ...field import Field
from ...spaces.power_space import PowerSpace
from ..endomorphic_operator import EndomorphicOperator
from ... import sqrt
from ... import nifty_utilities as utilities
class LaplaceOperator(EndomorphicOperator):
......
......@@ -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 ...nifty_meta import NiftyMeta
from keepers import Loggable
from nifty.field import Field
import nifty.nifty_utilities as utilities
from ...field import Field
from ... import 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,11 +16,11 @@
# 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
from nifty.operators.endomorphic_operator import EndomorphicOperator
from ...field import Field
from ..endomorphic_operator import EndomorphicOperator
class ProjectionOperator(EndomorphicOperator):
......@@ -99,7 +99,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 +124,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
from builtins import range
import numpy as np
from nifty import Field,\
FieldArray
from nifty.operators.linear_operator import LinearOperator
from nifty.operators.smoothing_operator import SmoothingOperator
from nifty.operators.composed_operator import ComposedOperator
from nifty.operators.diagonal_operator import DiagonalOperator
from ... import Field,\
FieldArray
from ..linear_operator import LinearOperator
from ..smoothing_operator import SmoothingOperator
from ..composed_operator import ComposedOperator
from ..diagonal_operator import DiagonalOperator
class ResponseOperator(LinearOperator):
......@@ -79,8 +80,8 @@ class ResponseOperator(LinearOperator):
raise ValueError("Length of smoothing kernel and length of"
"exposure do not match")
for ii in xrange(len(kernel_smoothing)):
kernel_smoothing[ii] = SmoothingOperator(self._domain[ii],
for ii in range(len(kernel_smoothing)):
kernel_smoothing[ii] = SmoothingOperator.make(self._domain[ii],
sigma=sigma[ii])
kernel_exposure[ii] = DiagonalOperator(self._domain[ii],
diagonal=exposure[ii])
......
# -*- coding: utf8 -*-
from __future__ import division
from builtins import range
import numpy as np
from d2o import STRATEGIES
......@@ -71,7 +73,7 @@ class DirectSmoothingOperator(SmoothingOperator):
return power[startindex:endindex]
p_smooth = np.zeros(endindex-startindex, dtype=power.dtype)
for i in xrange(startindex, endindex):
for i in range(startindex, endindex):
imin = max(startindex, ibegin[i])
imax = min(endindex, ibegin[i]+nval[i])
p_smooth[imin:imax] += (power[i] *
......@@ -95,7 +97,7 @@ class DirectSmoothingOperator(SmoothingOperator):
ind = np.zeros(nd-1, dtype=np.int)
i = np.zeros(nd, dtype=object)
shape = arr.shape
indlist = np.asarray(range(nd))
indlist = np.asarray(list(range(nd)))
indlist = np.delete(indlist, axis)
i[axis] = slice(None, None)
outshape = np.asarray(shape).take(indlist)
......
# -*- coding: utf-8 -*-
from builtins import range
import numpy as np
from nifty.operators.fft_operator import FFTOperator
......@@ -47,7 +49,7 @@ class FFTSmoothingOperator(SmoothingOperator):
local_kernel = kernel.get_local_data(copy=False)
reshaper = [local_transformed_x.shape[i] if i in coaxes else 1
for i in xrange(len(transformed_x.shape))]
for i in range(len(transformed_x.shape))]
local_kernel = np.reshape(local_kernel, reshaper)
# apply the kernel
......
......@@ -89,51 +89,44 @@ class SmoothingOperator(EndomorphicOperator):
"""
_fft_smoothing_spaces = [RGSpace,
GLSpace,
HPSpace]
_direct_smoothing_spaces = [PowerSpace]
def __new__(cls, domain, *args, **kwargs):
if cls is SmoothingOperator:
domain = cls._parse_domain(domain)
if len(domain) != 1:
raise ValueError("SmoothingOperator only accepts exactly one "
"space as input domain.")
if np.any([isinstance(domain[0], sp)
for sp in cls._fft_smoothing_spaces]):
from .fft_smoothing_operator import FFTSmoothingOperator
return super(SmoothingOperator, cls).__new__(
FFTSmoothingOperator, domain, *args, **kwargs)
elif np.any([isinstance(domain[0], sp)
for sp in cls._direct_smoothing_spaces]):
from .direct_smoothing_operator import DirectSmoothingOperator
return super(SmoothingOperator, cls).__new__(
DirectSmoothingOperator, domain, *args, **kwargs)
else:
raise NotImplementedError("For the given Space smoothing "
" is not available.")
@staticmethod
def make(domain, sigma, log_distances=False, default_spaces=None):
_fft_smoothing_spaces = [RGSpace,
GLSpace,
HPSpace]
_direct_smoothing_spaces = [PowerSpace]
domain = SmoothingOperator._parse_domain(domain)
if len(domain) != 1:
raise ValueError("SmoothingOperator only accepts exactly one "
"space as input domain.")
if np.any([isinstance(domain[0], sp)
for sp in _fft_smoothing_spaces]):
from .fft_smoothing_operator import FFTSmoothingOperator
return FFTSmoothingOperator (domain, sigma, log_distances,\
default_spaces)
elif np.any([isinstance(domain[0], sp)
for sp in _direct_smoothing_spaces]):
from .direct_smoothing_operator import DirectSmoothingOperator
return DirectSmoothingOperator (domain, sigma, log_distances,\
default_spaces)
else:
return super(SmoothingOperator, cls).__new__(cls,
domain,
*args,
**kwargs)
raise NotImplementedError("For the given Space smoothing "
" is not available.")
# ---Overwritten properties and methods---
def __init__(self, domain, sigma, log_distances=False,
default_spaces=None):
super(SmoothingOperator, self).__init__(default_spaces)
# # the _parse_domain is already done in the __new__ method
# self._domain = self._parse_domain(domain)
# if len(self.domain) != 1:
# raise ValueError("SmoothingOperator only accepts exactly one "
# "space as input domain.")
self._domain = self._parse_domain(domain)
if len(self._domain) != 1:
raise ValueError("SmoothingOperator only accepts exactly one "
"space as input domain.")
self._sigma = sigma
self._log_distances = log_distances
......
# -*- coding: utf-8 -*-
from smoothness_operator import SmoothnessOperator
from .smoothness_operator import SmoothnessOperator
from nifty.spaces.power_space import PowerSpace
from nifty.operators.endomorphic_operator import EndomorphicOperator
from nifty.operators.laplace_operator import LaplaceOperator
from ...spaces.power_space import PowerSpace
from ..endomorphic_operator import EndomorphicOperator
from ..laplace_operator import LaplaceOperator
class SmoothnessOperator(EndomorphicOperator):
......
from descriptors import *
from plots import *
from figures import *
from colormap import *
from plotter import *
from .descriptors import *
from .plots import *
from .figures import *
from .colormap import *
from .plotter import *
from colormap import Colormap
import colormaps
\ No newline at end of file
from .colormap import Colormap
from . import colormaps
from nifty.plotting.plotly_wrapper import PlotlyWrapper
from __future__ import division
from builtins import str
from ..plotly_wrapper import PlotlyWrapper
class Colormap(PlotlyWrapper):
......
from nifty.plotting.colormap.colormap import Colormap
from ..colormap.colormap import Colormap
def HighEnergyCmap():
......
from axis import Axis
from line import Line
from marker import Marker
from .axis import Axis
from .line import Line
from .marker import Marker
# -*- coding: utf-8 -*-
from nifty.plotting.plotly_wrapper import PlotlyWrapper
from ..plotly_wrapper import PlotlyWrapper
class Axis(PlotlyWrapper):
......
Supports Markdown
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