Commit 2866d426 authored by Philipp Arras's avatar Philipp Arras
Browse files

Cosmetics

parent c8773202
...@@ -27,6 +27,7 @@ from ..utilities import NiftyMetaBase ...@@ -27,6 +27,7 @@ from ..utilities import NiftyMetaBase
class Domain(NiftyMetaBase()): class Domain(NiftyMetaBase()):
"""The abstract class repesenting a (structured or unstructured) domain. """The abstract class repesenting a (structured or unstructured) domain.
""" """
def __init__(self): def __init__(self):
self._hash = None self._hash = None
......
...@@ -132,6 +132,7 @@ class LOSResponse(LinearOperator): ...@@ -132,6 +132,7 @@ class LOSResponse(LinearOperator):
every calling MPI task (i.e. the full LOS information has to be provided on every calling MPI task (i.e. the full LOS information has to be provided on
every task). every task).
""" """
def __init__(self, domain, starts, ends, sigmas_low=None, sigmas_up=None): def __init__(self, domain, starts, ends, sigmas_low=None, sigmas_up=None):
super(LOSResponse, self).__init__() super(LOSResponse, self).__init__()
......
...@@ -29,6 +29,7 @@ class RelaxedNewton(DescentMinimizer): ...@@ -29,6 +29,7 @@ class RelaxedNewton(DescentMinimizer):
The descent direction is determined by weighting the gradient at the The descent direction is determined by weighting the gradient at the
current parameter position with the inverse local metric. current parameter position with the inverse local metric.
""" """
def __init__(self, controller, line_searcher=None): def __init__(self, controller, line_searcher=None):
if line_searcher is None: if line_searcher is None:
line_searcher = LineSearchStrongWolfe( line_searcher = LineSearchStrongWolfe(
......
...@@ -28,5 +28,6 @@ class SteepestDescent(DescentMinimizer): ...@@ -28,5 +28,6 @@ class SteepestDescent(DescentMinimizer):
Also known as 'gradient descent'. This algorithm simply follows the Also known as 'gradient descent'. This algorithm simply follows the
functional's gradient for minimization. functional's gradient for minimization.
""" """
def get_descent_direction(self, energy): def get_descent_direction(self, energy):
return -energy.gradient return -energy.gradient
...@@ -106,6 +106,7 @@ class _InformationStore(object): ...@@ -106,6 +106,7 @@ class _InformationStore(object):
yy : numpy.ndarray yy : numpy.ndarray
2D circular buffer of scalar products between different elements of y. 2D circular buffer of scalar products between different elements of y.
""" """
def __init__(self, max_history_length, x0, gradient): def __init__(self, max_history_length, x0, gradient):
self.max_history_length = max_history_length self.max_history_length = max_history_length
self.s = [None]*max_history_length self.s = [None]*max_history_length
......
...@@ -35,6 +35,7 @@ def _joint_position(model1, model2): ...@@ -35,6 +35,7 @@ def _joint_position(model1, model2):
class ScalarMul(Model): class ScalarMul(Model):
"""Class representing a model multiplied by a scalar factor.""" """Class representing a model multiplied by a scalar factor."""
def __init__(self, factor, model): def __init__(self, factor, model):
super(ScalarMul, self).__init__(model.position) super(ScalarMul, self).__init__(model.position)
# TODO -> floating # TODO -> floating
...@@ -53,6 +54,7 @@ class ScalarMul(Model): ...@@ -53,6 +54,7 @@ class ScalarMul(Model):
class Add(Model): class Add(Model):
"""Class representing the sum of two models.""" """Class representing the sum of two models."""
def __init__(self, position, model1, model2): def __init__(self, position, model1, model2):
super(Add, self).__init__(position) super(Add, self).__init__(position)
...@@ -83,6 +85,7 @@ class Add(Model): ...@@ -83,6 +85,7 @@ class Add(Model):
class Mul(Model): class Mul(Model):
"""Class representing the pointwise product of two models.""" """Class representing the pointwise product of two models."""
def __init__(self, position, model1, model2): def __init__(self, position, model1, model2):
super(Mul, self).__init__(position) super(Mul, self).__init__(position)
......
...@@ -39,6 +39,7 @@ class Constant(Model): ...@@ -39,6 +39,7 @@ class Constant(Model):
- Position has no influence on value. - Position has no influence on value.
- The Jacobian is a null matrix. - The Jacobian is a null matrix.
""" """
def __init__(self, position, constant): def __init__(self, position, constant):
super(Constant, self).__init__(position) super(Constant, self).__init__(position)
self._constant = constant self._constant = constant
......
...@@ -47,6 +47,7 @@ class Model(NiftyMetaBase()): ...@@ -47,6 +47,7 @@ class Model(NiftyMetaBase()):
one automatically gets the value and Jacobian of the model. The 'at' method one automatically gets the value and Jacobian of the model. The 'at' method
creates a new instance of the class. creates a new instance of the class.
""" """
def __init__(self, position): def __init__(self, position):
self._position = position self._position = position
......
...@@ -27,6 +27,7 @@ from .model import Model ...@@ -27,6 +27,7 @@ from .model import Model
class MultiModel(Model): class MultiModel(Model):
""" """ """ """
def __init__(self, model, key): def __init__(self, model, key):
# TODO Rewrite it such that it takes a dictionary as input. # TODO Rewrite it such that it takes a dictionary as input.
# (just like MultiFields). # (just like MultiFields).
......
...@@ -31,6 +31,7 @@ class Variable(Model): ...@@ -31,6 +31,7 @@ class Variable(Model):
position : Field or MultiField position : Field or MultiField
The current position in parameter space. The current position in parameter space.
""" """
def __init__(self, position): def __init__(self, position):
super(Variable, self).__init__(position) super(Variable, self).__init__(position)
......
...@@ -34,6 +34,7 @@ class NullOperator(LinearOperator): ...@@ -34,6 +34,7 @@ class NullOperator(LinearOperator):
target : DomainTuple or MultiDomain target : DomainTuple or MultiDomain
output domain output domain
""" """
def __init__(self, domain, target): def __init__(self, domain, target):
from ..sugar import makeDomain from ..sugar import makeDomain
self._domain = makeDomain(domain) self._domain = makeDomain(domain)
......
...@@ -42,6 +42,7 @@ class QHTOperator(LinearOperator): ...@@ -42,6 +42,7 @@ class QHTOperator(LinearOperator):
The index of the domain on which the operator acts. The index of the domain on which the operator acts.
target[space] must be a nonharmonic LogRGSpace. target[space] must be a nonharmonic LogRGSpace.
""" """
def __init__(self, target, space=0): def __init__(self, target, space=0):
self._target = DomainTuple.make(target) self._target = DomainTuple.make(target)
self._space = infer_space(self._target, space) self._space = infer_space(self._target, space)
......
...@@ -111,4 +111,4 @@ class ScalingOperator(EndomorphicOperator): ...@@ -111,4 +111,4 @@ class ScalingOperator(EndomorphicOperator):
fct = 1./np.sqrt(fct) if from_inverse else np.sqrt(fct) fct = 1./np.sqrt(fct) if from_inverse else np.sqrt(fct)
cls = Field if isinstance(self._domain, DomainTuple) else MultiField cls = Field if isinstance(self._domain, DomainTuple) else MultiField
return cls.from_random( return cls.from_random(
random_type="normal", domain=self._domain, std=fct, dtype=dtype) random_type="normal", domain=self._domain, std=fct, dtype=dtype)
...@@ -35,6 +35,7 @@ class SelectionOperator(LinearOperator): ...@@ -35,6 +35,7 @@ class SelectionOperator(LinearOperator):
key : :class:`str` key : :class:`str`
String identifier of the wanted subdomain String identifier of the wanted subdomain
""" """
def __init__(self, domain, key): def __init__(self, domain, key):
self._domain = MultiDomain.make(domain) self._domain = MultiDomain.make(domain)
self._key = key self._key = key
......
...@@ -89,7 +89,7 @@ def get_slice_list(shape, axes): ...@@ -89,7 +89,7 @@ def get_slice_list(shape, axes):
slice_list = [ slice_list = [
next(it_iter) next(it_iter)
if axis else slice(None, None) for axis in axes_select if axis else slice(None, None) for axis in axes_select
] ]
yield slice_list yield slice_list
else: else:
yield [slice(None, None)] yield [slice(None, 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