There is a maintenance of MPCDF Gitlab on Thursday, April 22st 2020, 9:00 am CEST - Expect some service interruptions during this time

Commit 1762da4a authored by Martin Reinecke's avatar Martin Reinecke

changes for NIFTy_7, round 1

parent fe178ade
Pipeline #75106 failed with stages
in 31 seconds
......@@ -37,7 +37,7 @@ build_docker_from_cache:
test_serial:
stage: test
script:
- pytest-3 -q --cov=nifty6 test
- pytest-3 -q --cov=nifty7 test
- >
python3 -m coverage report --omit "*plot*" | tee coverage.txt
- >
......@@ -59,7 +59,7 @@ pages:
paths:
- public
only:
- NIFTy_5
- NIFTy_6
before_script:
......
NIFTy - Numerical Information Field Theory
==========================================
[![build status](https://gitlab.mpcdf.mpg.de/ift/NIFTy/badges/NIFTy_6/build.svg)](https://gitlab.mpcdf.mpg.de/ift/NIFTy/commits/NIFTy_6)
[![coverage report](https://gitlab.mpcdf.mpg.de/ift/NIFTy/badges/NIFTy_6/coverage.svg)](https://gitlab.mpcdf.mpg.de/ift/NIFTy/commits/NIFTy_6)
[![build status](https://gitlab.mpcdf.mpg.de/ift/NIFTy/badges/NIFTy_7/build.svg)](https://gitlab.mpcdf.mpg.de/ift/NIFTy/commits/NIFTy_7)
[![coverage report](https://gitlab.mpcdf.mpg.de/ift/NIFTy/badges/NIFTy_7/coverage.svg)](https://gitlab.mpcdf.mpg.de/ift/NIFTy/commits/NIFTy_7)
**NIFTy** project homepage:
[http://ift.pages.mpcdf.de/nifty](http://ift.pages.mpcdf.de/nifty)
......@@ -59,8 +59,8 @@ Optional dependencies:
### Sources
The current version of NIFTy6 can be obtained by cloning the repository and
switching to the NIFTy_6 branch:
The current version of NIFTy7 can be obtained by cloning the repository and
switching to the NIFTy_7 branch:
git clone https://gitlab.mpcdf.mpg.de/ift/nifty.git
......@@ -69,10 +69,10 @@ switching to the NIFTy_6 branch:
In the following, we assume a Debian-based distribution. For other
distributions, the "apt" lines will need slight changes.
NIFTy6 and its mandatory dependencies can be installed via:
NIFTy7 and its mandatory dependencies can be installed via:
sudo apt-get install git python3 python3-pip python3-dev
pip3 install --user git+https://gitlab.mpcdf.mpg.de/ift/nifty.git@NIFTy_6
pip3 install --user git+https://gitlab.mpcdf.mpg.de/ift/nifty.git@NIFTy_7
Plotting support is added via:
......@@ -107,7 +107,7 @@ To run the tests, additional packages are required:
Afterwards the tests (including a coverage report) can be run using the
following command in the repository root:
pytest-3 --cov=nifty6 test
pytest-3 --cov=nifty7 test
### First Steps
......
......@@ -3,7 +3,7 @@ from time import time
import matplotlib.pyplot as plt
import numpy as np
import nifty6 as ift
import nifty7 as ift
N0s, a0s, b0s, c0s = [], [], [], []
......
......@@ -24,7 +24,7 @@
import numpy as np
import nifty6 as ift
import nifty7 as ift
if __name__ == '__main__':
# Set up the position space of the signal
......
......@@ -140,7 +140,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"import nifty6 as ift\n",
"import nifty7 as ift\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline"
]
......
......@@ -25,7 +25,7 @@ import sys
import numpy as np
import nifty6 as ift
import nifty7 as ift
def make_checkerboard_mask(position_space):
......
......@@ -25,7 +25,7 @@ import sys
import numpy as np
import nifty6 as ift
import nifty7 as ift
def exposure_2d():
......
......@@ -29,7 +29,7 @@ import sys
import numpy as np
import nifty6 as ift
import nifty7 as ift
def random_los(n_los):
......
......@@ -29,7 +29,7 @@ import sys
import numpy as np
import nifty6 as ift
import nifty7 as ift
class SingleDomain(ift.LinearOperator):
......
import numpy as np
import nifty6 as ift
import nifty7 as ift
def convtest(test_signal, delta, func):
......
......@@ -18,7 +18,7 @@
import matplotlib.pyplot as plt
import numpy as np
import nifty6 as ift
import nifty7 as ift
def polynomial(coefficients, sampling_points):
......
rm -rf docs/build docs/source/mod
sphinx-apidoc -e -o docs/source/mod nifty6
sphinx-apidoc -e -o docs/source/mod nifty7
sphinx-build -b html docs/source/ docs/build/
......@@ -13,7 +13,7 @@ NIFTy-related publications
author = {{Martin Reinecke, Theo Steininger, Marco Selig}},
title = {NIFTy -- Numerical Information Field TheorY},
url = {https://gitlab.mpcdf.mpg.de/ift/NIFTy},
version = {nifty6},
version = {nifty7},
date = {2018-04-05},
}
......
......@@ -36,9 +36,9 @@ Domains
Abstract base class
-------------------
.. currentmodule:: nifty6.domains.domain
.. currentmodule:: nifty7.domains.domain
One of the fundamental building blocks of the NIFTy6 framework is the *domain*.
One of the fundamental building blocks of the NIFTy7 framework is the *domain*.
Its required capabilities are expressed by the abstract :py:class:`Domain` class.
A domain must be able to answer the following queries:
......@@ -52,7 +52,7 @@ A domain must be able to answer the following queries:
Unstructured domains
--------------------
.. currentmodule:: nifty6.domains.unstructured_domain
.. currentmodule:: nifty7.domains.unstructured_domain
Domains can be either *structured* (i.e. there is geometrical information
associated with them, like position in space and volume factors),
......@@ -65,7 +65,7 @@ Unstructured domains can be described by instances of NIFTy's
Structured domains
------------------
.. currentmodule:: nifty6.domains.structured_domain
.. currentmodule:: nifty7.domains.structured_domain
In contrast to unstructured domains, these domains have an assigned geometry.
NIFTy requires them to provide the volume elements of their grid cells.
......@@ -86,7 +86,7 @@ The additional methods are specified in the abstract class
NIFTy comes with several concrete subclasses of :class:`StructuredDomain`:
.. currentmodule:: nifty6.domains
.. currentmodule:: nifty7.domains
- :class:`~rg_space.RGSpace` represents a regular Cartesian grid with an arbitrary
number of dimensions, which is supposed to be periodic in each dimension.
......@@ -123,7 +123,7 @@ Some examples are:
(on a harmonic domain) and a few inferred model parameters (e.g. on an
unstructured grid).
.. currentmodule:: nifty6
.. currentmodule:: nifty7
Consequently, NIFTy defines a class called :class:`~domain_tuple.DomainTuple`
holding a sequence of :class:`~domains.domain.Domain` objects. The full domain is
......@@ -228,7 +228,7 @@ Advanced operators
NIFTy provides a library of commonly employed operators which can be used for
specific inference problems. Currently these are:
.. currentmodule:: nifty6.library
.. currentmodule:: nifty7.library
- :class:`~smooth_linear_amplitude.SLAmplitude`, which returns a smooth power spectrum.
- :class:`~inverse_gamma_operator.InverseGammaOperator`, which models point sources which are
......@@ -240,9 +240,9 @@ specific inference problems. Currently these are:
Linear Operators
================
.. currentmodule:: nifty6.operators
.. currentmodule:: nifty7.operators
A linear operator (represented by NIFTy6's abstract
A linear operator (represented by NIFTy7's abstract
:class:`~linear_operator.LinearOperator` class) is derived from
:class:`~operator.Operator` and can be interpreted as an (implicitly defined)
matrix. Since its operation is linear, it can provide some additional
......@@ -282,7 +282,7 @@ This functionality is provided by NIFTy's
:class:`~inversion_enabler.InversionEnabler` class, which is itself a linear
operator.
.. currentmodule:: nifty6.operators.operator
.. currentmodule:: nifty7.operators.operator
Direct multiplication and adjoint inverse multiplication transform a field
defined on the operator's :attr:`~Operator.domain` to one defined on the
......@@ -290,7 +290,7 @@ operator's :attr:`~Operator.target`, whereas adjoint multiplication and inverse
multiplication transform from :attr:`~Operator.target` to
:attr:`~Operator.domain`.
.. currentmodule:: nifty6.operators
.. currentmodule:: nifty7.operators
Operators with identical domain and target can be derived from
:class:`~endomorphic_operator.EndomorphicOperator`. Typical examples for this
......@@ -299,7 +299,7 @@ multiplies its input by a scalar value, and
:class:`~diagonal_operator.DiagonalOperator`, which multiplies every value of
its input field with potentially different values.
.. currentmodule:: nifty6
.. currentmodule:: nifty7
Further operator classes provided by NIFTy are
......@@ -325,7 +325,7 @@ and ``f1`` and ``f2`` are of type :class:`~field.Field`, writing::
X = A(B.inverse(A.adjoint)) + C
f2 = X(f1)
.. currentmodule:: nifty6.operators.linear_operator
.. currentmodule:: nifty7.operators.linear_operator
will perform the operation suggested intuitively by the notation, checking
domain compatibility while building the composed operator.
......@@ -349,12 +349,12 @@ Minimization
Most problems in IFT are solved by (possibly nested) minimizations of
high-dimensional functions, which are often nonlinear.
.. currentmodule:: nifty6.minimization
.. currentmodule:: nifty7.minimization
Energy functionals
------------------
In NIFTy6 such functions are represented by objects of type
In NIFTy7 such functions are represented by objects of type
:class:`~energy.Energy`. These hold the prescription how to calculate the
function's :attr:`~energy.Energy.value`, :attr:`~energy.Energy.gradient` and
(optionally) :attr:`~energy.Energy.metric` at any given
......@@ -362,11 +362,11 @@ function's :attr:`~energy.Energy.value`, :attr:`~energy.Energy.gradient` and
floating-point scalars, gradients have the form of fields defined on the energy's
position domain, and metrics are represented by linear operator objects.
.. currentmodule:: nifty6
.. currentmodule:: nifty7
Energies are classes that typically have to be provided by the user when
tackling new IFT problems. An example of concrete energy classes delivered with
NIFTy6 is :class:`~minimization.quadratic_energy.QuadraticEnergy` (with
NIFTy7 is :class:`~minimization.quadratic_energy.QuadraticEnergy` (with
position-independent metric, mainly used with conjugate gradient minimization).
For MGVI, NIFTy provides the :class:`~energy.Energy` subclass
......@@ -394,14 +394,14 @@ functional for MGVI and minimize it.
Iteration control
-----------------
.. currentmodule:: nifty6.minimization.iteration_controllers
.. currentmodule:: nifty7.minimization.iteration_controllers
Iterative minimization of an energy requires some means of
checking the quality of the current solution estimate and stopping once
it is sufficiently accurate. In case of numerical problems, the iteration needs
to be terminated as well, returning a suitable error description.
In NIFTy6, this functionality is encapsulated in the abstract
In NIFTy7, this functionality is encapsulated in the abstract
:class:`IterationController` class, which is provided with the initial energy
object before starting the minimization, and is updated with the improved
energy after every iteration. Based on this information, it can either continue
......@@ -418,7 +418,7 @@ in NIFTy can be found below, but users have complete freedom to implement custom
Minimization algorithms
-----------------------
.. currentmodule:: nifty6.minimization
.. currentmodule:: nifty7.minimization
All minimization algorithms in NIFTy inherit from the abstract
:class:`~minimizer.Minimizer` class, which presents a minimalistic interface
......@@ -459,7 +459,7 @@ available under the names :class:`~scipy_minimizer.ScipyCG` and
Application to operator inversion
---------------------------------
.. currentmodule:: nifty6
.. currentmodule:: nifty7
The machinery presented here cannot only be used for minimizing functionals
derived from IFT, but also for the numerical inversion of linear operators, if
......
import nifty6
import nifty7
extensions = [
'sphinx.ext.napoleon', # Support for NumPy and Google style docstrings
......@@ -15,11 +15,11 @@ napoleon_use_admonition_for_examples = True
napoleon_use_admonition_for_references = True
napoleon_include_special_with_doc = True
project = u'NIFTy6'
project = u'NIFTy7'
copyright = u'2013-2019, Max-Planck-Society'
author = u'Martin Reinecke'
release = nifty6.version.__version__
release = nifty7.version.__version__
version = release[:-2]
language = None
......@@ -30,5 +30,5 @@ html_theme = "sphinx_rtd_theme"
html_logo = 'nifty_logo_black.png'
exclude_patterns = [
'mod/modules.rst', 'mod/nifty6.git_version.rst', 'mod/nifty6.logger.rst'
'mod/modules.rst', 'mod/nifty7.git_version.rst', 'mod/nifty7.logger.rst'
]
......@@ -174,7 +174,7 @@ It only requires minimizing the information Hamiltonian, e.g. by a gradient desc
\frac{\partial \mathcal{H}(d,\xi)}{\partial \xi} = 0.
NIFTy6 automatically calculates the necessary gradient from a generative model of the signal and the data and uses this to minimize the Hamiltonian.
NIFTy7 automatically calculates the necessary gradient from a generative model of the signal and the data and uses this to minimize the Hamiltonian.
However, MAP often provides unsatisfactory results in cases of deep hirachical Bayesian networks.
The reason for this is that MAP ignores the volume factors in parameter space, which are not to be neglected in deciding whether a solution is reasonable or not.
......@@ -224,7 +224,7 @@ Thus, only the gradient of the KL is needed with respect to this, which can be e
We stochastically estimate the KL-divergence and gradients with a set of samples drawn from the approximate posterior distribution.
The particular structure of the covariance allows us to draw independent samples solving a certain system of equations.
This KL-divergence for MGVI is implemented in the class :class:`~minimization.metric_gaussian_kl.MetricGaussianKL` within NIFTy6.
This KL-divergence for MGVI is implemented in the class :class:`~minimization.metric_gaussian_kl.MetricGaussianKL` within NIFTy7.
The demo `getting_started_3.py` for example not only infers a field this way, but also the power spectrum of the process that has generated the field.
......
......@@ -31,4 +31,4 @@ Contents
installation
code
citations
Package Documentation <mod/nifty6>
Package Documentation <mod/nifty7>
......@@ -5,10 +5,10 @@ Installation
In the following, we assume a Debian-based Linux distribution. For other
distributions, the "apt" lines will need slight changes.
NIFTy6 and its mandatory dependencies can be installed via::
NIFTy7 and its mandatory dependencies can be installed via::
sudo apt-get install git python3 python3-pip python3-dev
pip3 install --user git+https://gitlab.mpcdf.mpg.de/ift/nifty.git@NIFTy_6
pip3 install --user git+https://gitlab.mpcdf.mpg.de/ift/nifty.git@NIFTy_7
Plotting support is added via::
......
......@@ -148,7 +148,7 @@ A visualisation of this can be seen in figure 2, which displays the MAP inferenc
Implementation in NIFTy
.......................
.. currentmodule:: nifty6
.. currentmodule:: nifty7
Most codes in NIFTy will contain the description of a measurement process or,
more generally, a log-likelihood.
......
......@@ -23,20 +23,20 @@ def write_version():
p = subprocess.Popen(["git", "describe", "--dirty", "--tags", "--always"],
stdout=subprocess.PIPE)
res = p.communicate()[0].strip().decode('utf-8')
with open("nifty6/git_version.py", "w") as file:
with open("nifty7/git_version.py", "w") as file:
file.write('gitversion = "{}"\n'.format(res))
write_version()
exec(open('nifty6/version.py').read())
exec(open('nifty7/version.py').read())
setup(name="nifty6",
setup(name="nifty7",
version=__version__,
author="Theo Steininger, Martin Reinecke",
author_email="martin@mpa-garching.mpg.de",
description="Numerical Information Field Theory",
url="http://www.mpa-garching.mpg.de/ift/nifty/",
packages=find_packages(include=["nifty6", "nifty6.*"]),
packages=find_packages(include=["nifty7", "nifty7.*"]),
zip_safe=True,
license="GPLv3",
setup_requires=['scipy>=1.4.1', 'numpy>=1.17'],
......
......@@ -99,4 +99,4 @@ from .linearization import Linearization
from .operator_spectrum import operator_spectrum
# We deliberately don't set __all__ here, because we don't want people to do a
# "from nifty6 import *"; that would swamp the global namespace.
# "from nifty7 import *"; that would swamp the global namespace.
......@@ -24,7 +24,7 @@ class GLSpace(StructuredDomain):
"""Represents a 2-sphere with Gauss-Legendre pixelization.
Its harmonic partner domain is the
:class:`~nifty6.domains.lm_space.LMSpace`.
:class:`~nifty7.domains.lm_space.LMSpace`.
Parameters
----------
......
......@@ -24,7 +24,7 @@ class HPSpace(StructuredDomain):
"""Represents 2-sphere with HEALPix discretization.
Its harmonic partner domain is the
:class:`~nifty6.domains.lm_space.LMSpace`.
:class:`~nifty7.domains.lm_space.LMSpace`.
Parameters
----------
......
......@@ -24,8 +24,8 @@ from .structured_domain import StructuredDomain
class LMSpace(StructuredDomain):
"""Represents a set of spherical harmonic coefficients.
Its harmonic partner spaces are :class:`~nifty6.domains.hp_space.HPSpace`
and :class:`~nifty6.domains.gl_space.GLSpace`.
Its harmonic partner spaces are :class:`~nifty7.domains.hp_space.HPSpace`
and :class:`~nifty7.domains.gl_space.GLSpace`.
Parameters
----------
......@@ -152,7 +152,7 @@ class LMSpace(StructuredDomain):
return self._mmax
def get_default_codomain(self):
"""Returns a :class:`~nifty6.domains.gl_space.GLSpace` object, which is
"""Returns a :class:`~nifty7.domains.gl_space.GLSpace` object, which is
capable of storing an accurate representation of data residing on
`self`.
......
......@@ -20,7 +20,7 @@ from .domain import Domain
class UnstructuredDomain(Domain):
"""A :class:`~nifty6.domains.domain.Domain` subclass for spaces with no
"""A :class:`~nifty7.domains.domain.Domain` subclass for spaces with no
associated geometry.
Typically used for data spaces.
......
......@@ -654,10 +654,10 @@ class Field(Operator):
return np.sqrt(self.s_var())
def __repr__(self):
return "<nifty6.Field>"
return "<nifty7.Field>"
def __str__(self):
return "nifty6.Field instance\n- domain = " + \
return "nifty7.Field instance\n- domain = " + \
self._domain.__str__() + \
"\n- val = " + repr(self._val)
......
......@@ -18,7 +18,7 @@
def _logger_init():
import logging
res = logging.getLogger('NIFTy6')
res = logging.getLogger('NIFTy7')
res.setLevel(logging.DEBUG)
res.propagate = False
ch = logging.StreamHandler()
......
......@@ -27,7 +27,7 @@ class ConjugateGradient(Minimizer):
Parameters
----------
controller : :py:class:`nifty6.IterationController`
controller : :py:class:`nifty7.IterationController`
Object that decides when to terminate the minimization.
nreset : int
every `nreset` CG steps the residual will be recomputed accurately
......