From fec4609f60e23aba665550cc588e3b98ec377d1f Mon Sep 17 00:00:00 2001 From: Martin Reinecke <martin@mpa-garching.mpg.de> Date: Wed, 14 Feb 2018 23:05:07 +0100 Subject: [PATCH] more doc work --- nifty4/domains/power_space.py | 16 ++++++------ nifty4/library/critical_power_energy.py | 19 +++++++------- nifty4/library/nonlinear_power_energy.py | 8 +++--- nifty4/minimization/conjugate_gradient.py | 4 +-- nifty4/minimization/descent_minimizer.py | 6 ++--- .../minimization/line_search_strong_wolfe.py | 18 ++++++------- nifty4/minimization/minimizer.py | 5 ++-- nifty4/minimization/nonlinear_cg.py | 4 +-- nifty4/minimization/vl_bfgs.py | 12 ++++----- nifty4/operators/laplace_operator.py | 2 +- nifty4/operators/linear_operator.py | 26 +++++++++---------- nifty4/operators/smoothness_operator.py | 4 +-- 12 files changed, 63 insertions(+), 61 deletions(-) diff --git a/nifty4/domains/power_space.py b/nifty4/domains/power_space.py index d4dc56ea0..1a0018019 100644 --- a/nifty4/domains/power_space.py +++ b/nifty4/domains/power_space.py @@ -24,14 +24,14 @@ from .. import dobj class PowerSpace(StructuredDomain): """NIFTy class for spaces of power spectra. - A power space is the result of a projection of a harmonic space where + A power space is the result of a projection of a harmonic domain where k-modes of equal length get mapped to one power index. Parameters ---------- - harmonic_partner : Space - The harmonic Space of which this is the power space. - binbounds: None, or tuple/array/list of float + harmonic_partner : StructuredDomain + The harmonic dmain of which this is the power space. + binbounds : None, or tuple of float if None: There will be as many bins as there are distinct k-vector lengths in the harmonic partner space. @@ -54,9 +54,9 @@ class PowerSpace(StructuredDomain): binbounds[0]=first_bound and binbounds[-1]=last_bound and the remaining values equidistantly spaced (in linear scale) between these two. - nbin: integer + nbin : int the number of bins - first_bound, last_bound: float + first_bound, last_bound : float the k values for the right boundary of the first bin and the left boundary of the last bin, respectively. They are given in length units of the harmonic partner space. @@ -74,9 +74,9 @@ class PowerSpace(StructuredDomain): values equidistantly spaced (in natural logarithmic scale) between these two. - nbin: integer + nbin : int the number of bins - first_bound, last_bound: float + first_bound, last_bound : float the k values for the right boundary of the first bin and the left boundary of the last bin, respectively. They are given in length units of the harmonic partner space. diff --git a/nifty4/library/critical_power_energy.py b/nifty4/library/critical_power_energy.py index bc0807131..9dfa1180e 100644 --- a/nifty4/library/critical_power_energy.py +++ b/nifty4/library/critical_power_energy.py @@ -34,33 +34,34 @@ class CriticalPowerEnergy(Energy): Parameters ---------- - position : Field, + position : Field The current position of this energy. (Logarithm of power spectrum) - m : Field, + m : Field The map whose power spectrum is inferred. Needs to live in harmonic signal space. - D : EndomorphicOperator, + D : EndomorphicOperator, optional The curvature of the Gaussian encoding the posterior covariance. If not specified, the map is assumed to be no reconstruction. default : None - alpha : float + alpha : float, optional The spectral prior of the inverse gamma distribution. 1.0 corresponds to non-informative. default : 1.0 - q : float + q : float, optional The cutoff parameter of the inverse gamma distribution. 0.0 corresponds to non-informative. default : 0.0 - smoothness_prior : float + smoothness_prior : float, optional Controls the strength of the smoothness prior default : 0.0 - logarithmic : boolean + logarithmic : bool, optional Whether smoothness acts on linear or logarithmic scale. - samples : integer + default : True + samples : int, optional Number of samples used for the estimation of the uncertainty corrections. default : 3 - w : Field + w : Field, optional The contribution from the map with or without uncertainty. It is used to pass on the result of the costly sampling during the minimization. default : None diff --git a/nifty4/library/nonlinear_power_energy.py b/nifty4/library/nonlinear_power_energy.py index 670757d1f..602427475 100644 --- a/nifty4/library/nonlinear_power_energy.py +++ b/nifty4/library/nonlinear_power_energy.py @@ -34,18 +34,18 @@ class NonlinearPowerEnergy(Energy): Parameters ---------- - position : Field, + position : Field The current position of this energy. - m : Field, + m : Field The map whichs power spectrum has to be inferred - D : EndomorphicOperator, + D : EndomorphicOperator The curvature of the Gaussian encoding the posterior covariance. If not specified, the map is assumed to be no reconstruction. default : None sigma : float The parameter of the smoothness prior. default : ??? None? ??????? - samples : integer + samples : int Number of samples used for the estimation of the uncertainty corrections. default : 3 diff --git a/nifty4/minimization/conjugate_gradient.py b/nifty4/minimization/conjugate_gradient.py index fad9d7333..974bb969e 100644 --- a/nifty4/minimization/conjugate_gradient.py +++ b/nifty4/minimization/conjugate_gradient.py @@ -56,9 +56,9 @@ class ConjugateGradient(Minimizer): Returns ------- - energy : QuadraticEnergy + QuadraticEnergy state at last point of the iteration - status : integer + int Can be controller.CONVERGED or controller.ERROR """ controller = self._controller diff --git a/nifty4/minimization/descent_minimizer.py b/nifty4/minimization/descent_minimizer.py index a4e45b01c..05a142030 100644 --- a/nifty4/minimization/descent_minimizer.py +++ b/nifty4/minimization/descent_minimizer.py @@ -50,15 +50,15 @@ class DescentMinimizer(Minimizer): Parameters ---------- - energy : Energy object + nergy : Energy Energy object which provides value, gradient and curvature at a specific position in parameter space. Returns ------- - energy : Energy object + Energy Latest `energy` of the minimization. - status : integer + int Can be controller.CONVERGED or controller.ERROR Notes diff --git a/nifty4/minimization/line_search_strong_wolfe.py b/nifty4/minimization/line_search_strong_wolfe.py index db87675c6..c53d8ad57 100644 --- a/nifty4/minimization/line_search_strong_wolfe.py +++ b/nifty4/minimization/line_search_strong_wolfe.py @@ -41,13 +41,13 @@ class LineSearchStrongWolfe(LineSearch): Parameter for curvature condition rule. (Default: 0.9) max_step_size : float Maximum step allowed in to be made in the descent direction. - (Default: 50) - max_iterations : integer + (Default: 1000000000) + max_iterations : int, optional Maximum number of iterations performed by the line search algorithm. - (Default: 10) - max_zoom_iterations : integer + (Default: 100) + max_zoom_iterations : int, optional Maximum number of iterations performed by the zoom algorithm. - (Default: 10) + (Default: 100) """ def __init__(self, c1=1e-4, c2=0.9, @@ -71,18 +71,18 @@ class LineSearchStrongWolfe(LineSearch): Parameters ---------- - energy : Energy object + energy : Energy Energy object from which we will calculate the energy and the gradient at a specific point. pk : Field Vector pointing into the search direction. - f_k_minus_1 : float + f_k_minus_1 : float, optional Value of the fuction (which is being minimized) at the k-1 iteration of the line search procedure. (Default: None) Returns ------- - energy_star : Energy object + Energy The new Energy object on the new position. """ le_0 = LineEnergy(0., energy, pk, 0.) @@ -188,7 +188,7 @@ class LineSearchStrongWolfe(LineSearch): Returns ------- - energy_star : Energy object + Energy The new Energy object on the new position. """ cubic_delta = 0.2 # cubic interpolant checks diff --git a/nifty4/minimization/minimizer.py b/nifty4/minimization/minimizer.py index 1c6ff8b94..bbcee440e 100644 --- a/nifty4/minimization/minimizer.py +++ b/nifty4/minimization/minimizer.py @@ -39,8 +39,9 @@ class Minimizer(with_metaclass(NiftyMeta, type('NewBase', (object,), {}))): Returns ------- - energy : Energy object + Energy Latest `energy` of the minimization. - status : integer + int + exit status of the minimization """ raise NotImplementedError diff --git a/nifty4/minimization/nonlinear_cg.py b/nifty4/minimization/nonlinear_cg.py index 32127e603..4b7146651 100644 --- a/nifty4/minimization/nonlinear_cg.py +++ b/nifty4/minimization/nonlinear_cg.py @@ -51,9 +51,9 @@ class NonlinearCG(Minimizer): Returns ------- - energy : + Energy state at last point of the iteration - status : integer + int Can be controller.CONVERGED or controller.ERROR """ controller = self._controller diff --git a/nifty4/minimization/vl_bfgs.py b/nifty4/minimization/vl_bfgs.py index f9da3dd3d..e9239417a 100644 --- a/nifty4/minimization/vl_bfgs.py +++ b/nifty4/minimization/vl_bfgs.py @@ -87,7 +87,7 @@ class InformationStore(object): Parameters ---------- - max_history_length : integer + max_history_length : int Maximum number of stored past updates. x0 : Field Initial position in variable space. @@ -96,7 +96,7 @@ class InformationStore(object): Attributes ---------- - max_history_length : integer + max_history_length : int Maximum number of stored past updates. s : List Circular buffer of past position differences, which are Fields. @@ -106,7 +106,7 @@ class InformationStore(object): Latest position in variable space. last_gradient : Field Gradient at latest position. - k : integer + k : int Number of updates that have taken place ss : numpy.ndarray 2D circular buffer of scalar products between different elements of s. @@ -139,7 +139,7 @@ class InformationStore(object): Returns ------- - result : List + List List of new basis vectors. """ result = [] @@ -165,7 +165,7 @@ class InformationStore(object): Returns ------- - result : numpy.ndarray + numpy.ndarray Scalar matrix. """ m = self.history_length @@ -207,7 +207,7 @@ class InformationStore(object): Returns ------- - delta : List + List List of the new scalar coefficients (deltas). """ m = self.history_length diff --git a/nifty4/operators/laplace_operator.py b/nifty4/operators/laplace_operator.py index 8b40a19fc..322e66434 100644 --- a/nifty4/operators/laplace_operator.py +++ b/nifty4/operators/laplace_operator.py @@ -35,7 +35,7 @@ class LaplaceOperator(EndomorphicOperator): Parameters ---------- - logarithmic : boolean, + logarithmic : bool, optional Whether smoothness is calculated on a logarithmic scale or linear scale default : True space : int diff --git a/nifty4/operators/linear_operator.py b/nifty4/operators/linear_operator.py index 96009d723..0993eb1ce 100644 --- a/nifty4/operators/linear_operator.py +++ b/nifty4/operators/linear_operator.py @@ -57,7 +57,7 @@ class LinearOperator(with_metaclass( @abc.abstractproperty def domain(self): """ - domain : DomainTuple + DomainTuple The domain on which the Operator's input Field lives. Every Operator which inherits from the abstract LinearOperator base class must have this attribute. @@ -67,7 +67,7 @@ class LinearOperator(with_metaclass( @abc.abstractproperty def target(self): """ - target : DomainTuple + DomainTuple The domain on which the Operator's output Field lives. Every Operator which inherits from the abstract LinearOperator base class must have this attribute. @@ -77,7 +77,7 @@ class LinearOperator(with_metaclass( @property def inverse(self): """ - inverse : LinearOperator + LinearOperator Returns a LinearOperator object which behaves as if it were the inverse of this operator. """ @@ -87,7 +87,7 @@ class LinearOperator(with_metaclass( @property def adjoint(self): """ - adjoint : LinearOperator + LinearOperator Returns a LinearOperator object which behaves as if it were the adjoint of this operator. """ @@ -141,7 +141,7 @@ class LinearOperator(with_metaclass( Returns ------- - out : integer + int This is any subset of LinearOperator.{TIMES, ADJOINT_TIMES, INVERSE_TIMES, ADJOINT_INVERSE_TIMES, INVERSE_ADJOINT_TIMES}, joined together by the "|" operator. @@ -158,7 +158,7 @@ class LinearOperator(with_metaclass( The input Field, living on the Operator's domain or target, depending on mode. - mode : integer + mode : int LinearOperator.TIMES: normal application LinearOperator.ADJOINT_TIMES: adjoint application LinearOperator.INVERSE_TIMES: inverse application @@ -168,7 +168,7 @@ class LinearOperator(with_metaclass( Returns ------- - out : Field + Field The processed Field living on the Operator's target or domain, depending on mode. """ @@ -188,7 +188,7 @@ class LinearOperator(with_metaclass( Returns ------- - out : Field + Field The processed Field living on the Operator's target domain. """ return self.apply(x, self.TIMES) @@ -203,7 +203,7 @@ class LinearOperator(with_metaclass( Returns ------- - out : Field + Field The processed Field living on the Operator's domain. """ return self.apply(x, self.INVERSE_TIMES) @@ -218,7 +218,7 @@ class LinearOperator(with_metaclass( Returns ------- - out : Field + Field The processed Field living on the Operator's domain. """ return self.apply(x, self.ADJOINT_TIMES) @@ -233,7 +233,7 @@ class LinearOperator(with_metaclass( Returns ------- - out : Field + Field The processed Field living on the Operator's target domain. Notes @@ -267,7 +267,7 @@ class LinearOperator(with_metaclass( Returns ------- - sample : Field - Returns the a sample from the Gaussian of given covariance. + Field + A sample from the Gaussian of given covariance. """ raise NotImplementedError diff --git a/nifty4/operators/smoothness_operator.py b/nifty4/operators/smoothness_operator.py index 682578f40..adb554ddb 100644 --- a/nifty4/operators/smoothness_operator.py +++ b/nifty4/operators/smoothness_operator.py @@ -36,9 +36,9 @@ def SmoothnessOperator(domain, strength=1., logarithmic=True, space=None): Parameters ---------- - strength: nonnegative float + strength : nonnegative float Specifies the strength of the SmoothnessOperator - logarithmic : boolean + logarithmic : bool, optional Whether smoothness is calculated on a logarithmic scale or linear scale default : True """ -- GitLab