Commit a8302a53 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

more PEP8

parent 7306562b
......@@ -23,6 +23,7 @@ from itertools import product
import itertools
from functools import reduce
def get_slice_list(shape, axes):
"""
Helper function which generates slice list(s) to traverse over all
......@@ -111,6 +112,8 @@ def parse_domain(domain):
"Given object contains something that is not an "
"instance of DomainObject-class.")
return domain
def slicing_generator(shape, axes):
"""
Helper function which generates slice list(s) to traverse over all
......@@ -154,6 +157,7 @@ def slicing_generator(shape, axes):
yield [slice(None, None)]
return
def bincount_axis(obj, minlength=None, weights=None, axis=None):
if minlength is not None:
length = max(np.amax(obj) + 1, minlength)
......
......@@ -98,7 +98,8 @@ class DiagonalOperator(EndomorphicOperator):
operation=lambda z: z.adjoint().__mul__)
def _inverse_times(self, x, spaces):
return self._times_helper(x, spaces, operation=lambda z: z.__rtruediv__)
return self._times_helper(x, spaces,
operation=lambda z: z.__rtruediv__)
def _adjoint_inverse_times(self, x, spaces):
return self._times_helper(x, spaces,
......@@ -221,4 +222,4 @@ class DiagonalOperator(EndomorphicOperator):
# here the actual multiplication takes place
local_result = operation(reshaped_local_diagonal)(x.val)
return Field (x.domain,val=local_result)
return Field(x.domain, val=local_result)
......@@ -16,8 +16,6 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
import numpy as np
from ... import nifty_utilities as utilities
from ...spaces import RGSpace,\
GLSpace,\
......
......@@ -20,7 +20,7 @@ from __future__ import division
import numpy as np
from .transformation import Transformation
from .rg_transforms import SerialFFT
from .... import RGSpace
class RGRGTransformation(Transformation):
......@@ -36,7 +36,6 @@ class RGRGTransformation(Transformation):
def unitary(self):
return True
def transform(self, val, axes=None):
"""
RG -> RG transform method.
......
......@@ -29,7 +29,7 @@ class SlicingTransformation(Transformation):
return_shape = np.array(val.shape)
return_shape[list(axes)] = self.codomain.shape
return_shape = tuple(return_shape)
return_val = np.empty(return_shape,dtype=val.dtype)
return_val = np.empty(return_shape, dtype=val.dtype)
for slice_list in utilities.get_slice_list(val.shape, axes):
return_val[slice_list] = self._transformation_of_slice(
......
......@@ -21,7 +21,8 @@ import abc
from future.utils import with_metaclass
class Transformation(with_metaclass(abc.ABCMeta, type('NewBase', (object,), {}))):
class Transformation(with_metaclass(abc.ABCMeta,
type('NewBase', (object,), {}))):
def __init__(self, domain, codomain):
self.domain = domain
......
......@@ -186,9 +186,8 @@ class DirectSmoothingOperator(EndomorphicOperator):
distance_array = x.domain[spaces[0]].get_distance_array()
#MR FIXME: this causes calls of log(0.) which should probably be avoided
if self.log_distances:
np.log(np.maximum(distance_array,1e-15), out=distance_array)
np.log(np.maximum(distance_array, 1e-15), out=distance_array)
augmented_data = x.val
augmented_distance_array = distance_array
......
......@@ -62,7 +62,6 @@ class FFTSmoothingOperator(EndomorphicOperator):
coaxes = transformed_x.domain_axes[spaces[0]]
kernel = codomain.get_distance_array()
kernel = codomain.get_fft_smoothing_kernel_function(self.sigma)(kernel)
# now, apply the kernel to transformed_x
......@@ -77,15 +76,9 @@ class FFTSmoothingOperator(EndomorphicOperator):
local_transformed_x *= local_kernel
transformed_x.val=local_transformed_x
smoothed_x = transformator.adjoint_times(transformed_x,
spaces=spaces)
result = x.copy_empty()
result=smoothed_x
transformed_x.val = local_transformed_x
return result
return transformator.adjoint_times(transformed_x, spaces=spaces)
def _get_transformator(self, dtype):
if dtype not in self._transformator_cache:
......
......@@ -24,6 +24,7 @@ import numpy as np
from ..space import Space
import pyHealpix
class GLSpace(Space):
"""
.. __
......@@ -177,7 +178,7 @@ class GLSpace(Space):
def get_default_codomain(self):
from .. import LMSpace
return LMSpace(lmax=self.nlat-1,mmax=(self.nlon-1)//2)
return LMSpace(lmax=self.nlat-1, mmax=(self.nlon-1)//2)
def check_codomain(self, codomain):
from .. import LMSpace
......
......@@ -16,7 +16,6 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
import ast
import numpy as np
from ...spaces.space import Space
......@@ -137,7 +136,7 @@ class PowerSpace(Space):
temp_rho = np.bincount(temp_pindex.flatten())
assert not np.any(temp_rho == 0), "empty bins detected"
temp_kindex = np.bincount(temp_pindex.flatten(),
weights=distance_array.flatten()) / temp_rho
weights=distance_array.flatten()) / temp_rho
self._powerIndexCache[key] = (binbounds,
temp_pindex,
temp_kindex,
......@@ -148,7 +147,6 @@ class PowerSpace(Space):
@staticmethod
def _compute_pindex(harmonic_partner, distance_array, binbounds):
pindex = np.empty(distance_array.shape,dtype=np.int)
if binbounds is None:
binbounds = harmonic_partner.get_natural_binbounds()
return np.searchsorted(binbounds, distance_array)
......
......@@ -230,7 +230,6 @@ class RGSpace(Space):
raise AttributeError("The grid-distances of domain and codomain "
"do not match.")
# ---Added properties and methods---
@property
......
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