Commit 94e8fc43 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

Merge branch 'extra_docu' into 'NIFTy_5'

added docu to the checks

See merge request ift/nifty-dev!209
parents b18ec7d8 6007131f
...@@ -74,25 +74,31 @@ def _check_linearity(op, domain_dtype, atol, rtol): ...@@ -74,25 +74,31 @@ def _check_linearity(op, domain_dtype, atol, rtol):
def consistency_check(op, domain_dtype=np.float64, target_dtype=np.float64, def consistency_check(op, domain_dtype=np.float64, target_dtype=np.float64,
atol=0, rtol=1e-7): atol=0, rtol=1e-7):
"""Checks whether times(), adjoint_times(), inverse_times() and """
Checks an operator for algebraic consistency of its capabilities.
Checks whether times(), adjoint_times(), inverse_times() and
adjoint_inverse_times() (if in capability list) is implemented adjoint_inverse_times() (if in capability list) is implemented
consistently. Additionally, it checks whether the operator is linear consistently. Additionally, it checks whether the operator is linear.
actually.
Parameters Parameters
---------- ----------
op : LinearOperator op : LinearOperator
Operator which shall be checked. Operator which shall be checked.
domain_dtype : FIXME domain_dtype : dtype
The data type of the random vectors in the operator's domain. Default The data type of the random vectors in the operator's domain. Default
is `np.float64`. is `np.float64`.
target_dtype : FIXME target_dtype : dtype
The data type of the random vectors in the operator's target. Default The data type of the random vectors in the operator's target. Default
is `np.float64`. is `np.float64`.
atol : float atol : float
FIXME. Default is 0. Absolute tolerance for the check. If rtol is specified,
then satisfying any tolerance will let the check pass.
Default: 0.
rtol : float rtol : float
FIXME. Default is 0. Relative tolerance for the check. If atol is specified,
then satisfying any tolerance will let the check pass.
Default: 0.
""" """
if not isinstance(op, LinearOperator): if not isinstance(op, LinearOperator):
raise TypeError('This test tests only linear operators.') raise TypeError('This test tests only linear operators.')
...@@ -157,7 +163,28 @@ def _check_consistency(op, loc, tol, ntries, do_metric): ...@@ -157,7 +163,28 @@ def _check_consistency(op, loc, tol, ntries, do_metric):
def check_value_gradient_consistency(op, loc, tol=1e-8, ntries=100): def check_value_gradient_consistency(op, loc, tol=1e-8, ntries=100):
"""FIXME""" """
Checks the gradient (jacobian) of an operator against its value.
Computes the gradient (jacobian) with finite differences and compares
it to the implemented gradient (jacobian).
Parameters
----------
op : Operator
Operator which shall be checked.
loc : Field or MultiField
An Field or MultiField instance which has the same domain
as op. The location at which the gradient is checked
atol : float
Absolute tolerance for the check. If rtol is specified,
then satisfying any tolerance will let the check pass.
Default: 0.
rtol : float
Relative tolerance for the check. If atol is specified,
then satisfying any tolerance will let the check pass.
Default: 0
"""
_check_consistency(op, loc, tol, ntries, False) _check_consistency(op, loc, tol, ntries, False)
......
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