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

merge NIFTy_5

parents 307c6db6 addd0938
...@@ -34,32 +34,24 @@ build_docker_from_cache: ...@@ -34,32 +34,24 @@ build_docker_from_cache:
- docker build -t $CONTAINER_TEST_IMAGE . - docker build -t $CONTAINER_TEST_IMAGE .
- docker push $CONTAINER_TEST_IMAGE - docker push $CONTAINER_TEST_IMAGE
test_python2_with_coverage: test:
stage: test stage: test
variables: variables:
OMPI_MCA_btl_vader_single_copy_mechanism: none OMPI_MCA_btl_vader_single_copy_mechanism: none
script: script:
- mpiexec -n 2 --bind-to none pytest -q test - mpiexec -n 2 --bind-to none pytest-3 -q test
- pytest -q --cov=nifty5 test - pytest-3 -q --cov=nifty5 test
- > - >
python -m coverage report --omit "*plotting*,*distributed_do*" python3 -m coverage report --omit "*plotting*,*distributed_do*"
- > - >
python -m coverage report --omit "*plotting*,*distributed_do*" | grep TOTAL | awk '{ print "TOTAL: "$4; }' python3 -m coverage report --omit "*plotting*,*distributed_do*" | grep TOTAL | awk '{ print "TOTAL: "$4; }'
test_python3:
stage: test
variables:
OMPI_MCA_btl_vader_single_copy_mechanism: none
script:
- pytest-3 -q
- mpiexec -n 2 --bind-to none pytest-3 -q
pages: pages:
stage: release stage: release
before_script: before_script:
- ls - ls
script: script:
- python setup.py install --user -f - python3 setup.py install --user -f
- sh docs/generate.sh - sh docs/generate.sh
- mv docs/build/ public/ - mv docs/build/ public/
artifacts: artifacts:
...@@ -69,7 +61,6 @@ pages: ...@@ -69,7 +61,6 @@ pages:
- NIFTy_4 - NIFTy_4
before_script: before_script:
- python setup.py install --user -f
- python3 setup.py install --user -f - python3 setup.py install --user -f
run_ipynb: run_ipynb:
...@@ -80,7 +71,6 @@ run_ipynb: ...@@ -80,7 +71,6 @@ run_ipynb:
run_getting_started_1: run_getting_started_1:
stage: demo_runs stage: demo_runs
script: script:
- python demos/getting_started_1.py
- python3 demos/getting_started_1.py - python3 demos/getting_started_1.py
- mpiexec -n 2 --bind-to none python3 demos/getting_started_1.py 2> /dev/null - mpiexec -n 2 --bind-to none python3 demos/getting_started_1.py 2> /dev/null
artifacts: artifacts:
...@@ -90,7 +80,6 @@ run_getting_started_1: ...@@ -90,7 +80,6 @@ run_getting_started_1:
run_getting_started_2: run_getting_started_2:
stage: demo_runs stage: demo_runs
script: script:
- python demos/getting_started_2.py
- python3 demos/getting_started_2.py - python3 demos/getting_started_2.py
- mpiexec -n 2 --bind-to none python3 demos/getting_started_2.py 2> /dev/null - mpiexec -n 2 --bind-to none python3 demos/getting_started_2.py 2> /dev/null
artifacts: artifacts:
...@@ -100,7 +89,6 @@ run_getting_started_2: ...@@ -100,7 +89,6 @@ run_getting_started_2:
run_getting_started_3: run_getting_started_3:
stage: demo_runs stage: demo_runs
script: script:
- python demos/getting_started_3.py
- python3 demos/getting_started_3.py - python3 demos/getting_started_3.py
artifacts: artifacts:
paths: paths:
...@@ -109,7 +97,6 @@ run_getting_started_3: ...@@ -109,7 +97,6 @@ run_getting_started_3:
run_bernoulli: run_bernoulli:
stage: demo_runs stage: demo_runs
script: script:
- python demos/bernoulli_demo.py
- python3 demos/bernoulli_demo.py - python3 demos/bernoulli_demo.py
artifacts: artifacts:
paths: paths:
...@@ -118,7 +105,6 @@ run_bernoulli: ...@@ -118,7 +105,6 @@ run_bernoulli:
run_curve_fitting: run_curve_fitting:
stage: demo_runs stage: demo_runs
script: script:
- python demos/polynomial_fit.py
- python3 demos/polynomial_fit.py - python3 demos/polynomial_fit.py
artifacts: artifacts:
paths: paths:
......
...@@ -5,27 +5,23 @@ RUN apt-get update && apt-get install -y \ ...@@ -5,27 +5,23 @@ RUN apt-get update && apt-get install -y \
git \ git \
# Packages needed for NIFTy # Packages needed for NIFTy
libfftw3-dev \ libfftw3-dev \
python python-pip python-dev python-future python-scipy cython \
python3 python3-pip python3-dev python3-future python3-scipy cython3 \ python3 python3-pip python3-dev python3-future python3-scipy cython3 \
# Documentation build dependencies # Documentation build dependencies
python-sphinx python-sphinx-rtd-theme python-numpydoc \ python3-sphinx python3-sphinx-rtd-theme python3-numpydoc \
# Testing dependencies # Testing dependencies
python-nose python-coverage python-parameterized python-pytest python-pytest-cov \ python3-coverage python3-parameterized python3-pytest python3-pytest-cov \
python3-nose python3-coverage python3-parameterized python3-pytest python3-pytest-cov \
# Optional NIFTy dependencies # Optional NIFTy dependencies
openmpi-bin libopenmpi-dev python-mpi4py python3-mpi4py \ openmpi-bin libopenmpi-dev python3-mpi4py \
# Packages needed for NIFTy # Packages needed for NIFTy
&& pip install pyfftw \
&& pip3 install pyfftw \ && pip3 install pyfftw \
# Optional NIFTy dependencies # Optional NIFTy dependencies
&& pip install git+https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git \
&& pip3 install git+https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git \ && pip3 install git+https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git \
# Testing dependencies # Testing dependencies
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Needed for demos to be running # Needed for demos to be running
RUN apt-get update && apt-get install -y python-matplotlib python3-matplotlib \ RUN apt-get update && apt-get install -y python3-matplotlib \
&& python3 -m pip install --upgrade pip && python3 -m pip install jupyter && python -m pip install --upgrade pip && python -m pip install jupyter \ && python3 -m pip install --upgrade pip && python3 -m pip install jupyter \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Set matplotlib backend # Set matplotlib backend
......
...@@ -37,7 +37,7 @@ Installation ...@@ -37,7 +37,7 @@ Installation
### Requirements ### Requirements
- [Python](https://www.python.org/) (v2.7.x or 3.5.x) - [Python 3](https://www.python.org/) (3.5.x or later)
- [SciPy](https://www.scipy.org/) - [SciPy](https://www.scipy.org/)
- [pyFFTW](https://pypi.python.org/pypi/pyFFTW) - [pyFFTW](https://pypi.python.org/pypi/pyFFTW)
...@@ -61,8 +61,8 @@ distributions, the "apt" lines will need slight changes. ...@@ -61,8 +61,8 @@ distributions, the "apt" lines will need slight changes.
NIFTy5 and its mandatory dependencies can be installed via: NIFTy5 and its mandatory dependencies can be installed via:
sudo apt-get install git libfftw3-dev python python-pip python-dev sudo apt-get install git libfftw3-dev python3 python3-pip python3-dev
pip install --user git+https://gitlab.mpcdf.mpg.de/ift/NIFTy.git@NIFTy_5 pip3 install --user git+https://gitlab.mpcdf.mpg.de/ift/NIFTy.git@NIFTy_5
(Note: If you encounter problems related to `pyFFTW`, make sure that you are (Note: If you encounter problems related to `pyFFTW`, make sure that you are
using a pip-installed `pyFFTW` package. Unfortunately, some distributions are using a pip-installed `pyFFTW` package. Unfortunately, some distributions are
...@@ -71,35 +71,26 @@ with the installed `FFTW3` libraries.) ...@@ -71,35 +71,26 @@ with the installed `FFTW3` libraries.)
Plotting support is added via: Plotting support is added via:
pip install --user matplotlib pip3 install --user matplotlib
Support for spherical harmonic transforms is added via: Support for spherical harmonic transforms is added via:
pip install --user git+https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git pip3 install --user git+https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git
MPI support is added via: MPI support is added via:
sudo apt-get install openmpi-bin libopenmpi-dev sudo apt-get install openmpi-bin libopenmpi-dev
pip install --user mpi4py pip3 install --user mpi4py
### Installation for Python 3
If you want to run NIFTy with Python 3, you need to make the following changes
to the instructions above:
- in all `apt-get` commands, replace `python-*` by `python3-*`
- in all `pip` commands, replace `pip` by `pip3`
### Running the tests ### Running the tests
In oder to run the tests one needs two additional packages: In oder to run the tests one needs two additional packages:
sudo apt-get install python3-coverage python3-parameterized python3-pytest python3-pytest-cov
pip install --user nose parameterized coverage
Afterwards the tests (including a coverage report) can be run using the Afterwards the tests (including a coverage report) can be run using the
following command in the repository root: following command in the repository root:
nosetests -x --with-coverage --cover-html --cover-package=nifty5 pytest-3 --cov=nifty5 test
### First Steps ### First Steps
...@@ -108,7 +99,7 @@ For a quick start, you can browse through the [informal ...@@ -108,7 +99,7 @@ For a quick start, you can browse through the [informal
introduction](http://ift.pages.mpcdf.de/NIFTy/code.html) or introduction](http://ift.pages.mpcdf.de/NIFTy/code.html) or
dive into NIFTy by running one of the demonstrations, e.g.: dive into NIFTy by running one of the demonstrations, e.g.:
python demos/getting_started_1.py python3 demos/getting_started_1.py
### Acknowledgement ### Acknowledgement
......
...@@ -11,10 +11,9 @@ ...@@ -11,10 +11,9 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# Copyright(C) 2013-2018 Max-Planck-Society # Copyright(C) 2013-2019 Max-Planck-Society
# #
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
# and financially supported by the Studienstiftung des deutschen Volkes.
import nifty5 as ift import nifty5 as ift
import numpy as np import numpy as np
......
...@@ -11,10 +11,9 @@ ...@@ -11,10 +11,9 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# Copyright(C) 2013-2018 Max-Planck-Society # Copyright(C) 2013-2019 Max-Planck-Society
# #
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
# and financially supported by the Studienstiftung des deutschen Volkes.
import nifty5 as ift import nifty5 as ift
import numpy as np import numpy as np
...@@ -78,7 +77,10 @@ if __name__ == '__main__': ...@@ -78,7 +77,10 @@ if __name__ == '__main__':
GR = ift.GeometryRemover(position_space) GR = ift.GeometryRemover(position_space)
mask = ift.Field.from_global_data(position_space, mask) mask = ift.Field.from_global_data(position_space, mask)
Mask = ift.DiagonalOperator(mask) Mask = ift.DiagonalOperator(mask)
# Operators can be composed either with paranthesis
R = GR(Mask(HT)) R = GR(Mask(HT))
# or with @
R = GR @ Mask @ HT
data_space = GR.target data_space = GR.target
...@@ -93,7 +95,7 @@ if __name__ == '__main__': ...@@ -93,7 +95,7 @@ if __name__ == '__main__':
# Build propagator D and information source j # Build propagator D and information source j
j = R.adjoint_times(N.inverse_times(data)) j = R.adjoint_times(N.inverse_times(data))
D_inv = R.adjoint(N.inverse(R)) + S.inverse D_inv = R.adjoint @ N.inverse @ R + S.inverse
# Make it invertible # Make it invertible
IC = ift.GradientNormController(iteration_limit=500, tol_abs_gradnorm=1e-3) IC = ift.GradientNormController(iteration_limit=500, tol_abs_gradnorm=1e-3)
D = ift.InversionEnabler(D_inv, IC, approximation=S.inverse).inverse D = ift.InversionEnabler(D_inv, IC, approximation=S.inverse).inverse
...@@ -105,15 +107,16 @@ if __name__ == '__main__': ...@@ -105,15 +107,16 @@ if __name__ == '__main__':
rg = isinstance(position_space, ift.RGSpace) rg = isinstance(position_space, ift.RGSpace)
plot = ift.Plot() plot = ift.Plot()
if rg and len(position_space.shape) == 1: if rg and len(position_space.shape) == 1:
plot.add([HT(MOCK_SIGNAL), GR.adjoint(data), HT(m)], plot.add(
label=['Mock signal', 'Data', 'Reconstruction'], [HT(MOCK_SIGNAL), GR.adjoint(data),
alpha=[1, .3, 1]) HT(m)],
plot.add(mask_to_nan(mask, HT(m-MOCK_SIGNAL)), title='Residuals') label=['Mock signal', 'Data', 'Reconstruction'],
alpha=[1, .3, 1])
plot.add(mask_to_nan(mask, HT(m - MOCK_SIGNAL)), title='Residuals')
plot.output(nx=2, ny=1, xsize=10, ysize=4, title="getting_started_1") plot.output(nx=2, ny=1, xsize=10, ysize=4, title="getting_started_1")
else: else:
plot.add(HT(MOCK_SIGNAL), title='Mock Signal') plot.add(HT(MOCK_SIGNAL), title='Mock Signal')
plot.add(mask_to_nan(mask, (GR(Mask)).adjoint(data)), plot.add(mask_to_nan(mask, (GR(Mask)).adjoint(data)), title='Data')
title='Data')
plot.add(HT(m), title='Reconstruction') plot.add(HT(m), title='Reconstruction')
plot.add(mask_to_nan(mask, HT(m-MOCK_SIGNAL)), title='Residuals') plot.add(mask_to_nan(mask, HT(m-MOCK_SIGNAL)), title='Residuals')
plot.output(nx=2, ny=2, xsize=10, ysize=10, title="getting_started_1") plot.output(nx=2, ny=2, xsize=10, ysize=10, title="getting_started_1")
...@@ -11,10 +11,9 @@ ...@@ -11,10 +11,9 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# Copyright(C) 2013-2018 Max-Planck-Society # Copyright(C) 2013-2019 Max-Planck-Society
# #
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
# and financially supported by the Studienstiftung des deutschen Volkes.
import nifty5 as ift import nifty5 as ift
import numpy as np import numpy as np
......
...@@ -11,10 +11,9 @@ ...@@ -11,10 +11,9 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# Copyright(C) 2013-2018 Max-Planck-Society # Copyright(C) 2013-2019 Max-Planck-Society
# #
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
# and financially supported by the Studienstiftung des deutschen Volkes.
import nifty5 as ift import nifty5 as ift
import numpy as np import numpy as np
......
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2019 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import nifty5 as ift import nifty5 as ift
import numpy as np import numpy as np
......
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2019 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
......
...@@ -52,9 +52,6 @@ extensions = [ ...@@ -52,9 +52,6 @@ extensions = [
'numpydoc', 'numpydoc',
'sphinx.ext.autosummary', 'sphinx.ext.autosummary',
'sphinx.ext.napoleon', 'sphinx.ext.napoleon',
# 'sphinx.ext.coverage',
# 'sphinx.ext.todo',
# 'sphinx.ext.mathjax',
'sphinx.ext.imgmath', 'sphinx.ext.imgmath',
'sphinx.ext.viewcode' 'sphinx.ext.viewcode'
] ]
...@@ -75,7 +72,7 @@ master_doc = 'index' ...@@ -75,7 +72,7 @@ master_doc = 'index'
# General information about the project. # General information about the project.
project = u'NIFTy5' project = u'NIFTy5'
copyright = u'2013-2018, Max-Planck-Society' copyright = u'2013-2019, Max-Planck-Society'
author = u'Theo Steininger / Martin Reinecke' author = u'Theo Steininger / Martin Reinecke'
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
...@@ -94,20 +91,10 @@ release = u'5.0.0' ...@@ -94,20 +91,10 @@ release = u'5.0.0'
# Usually you set "language" from the command line for these cases. # Usually you set "language" from the command line for these cases.
language = None language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
exclude_patterns = [] exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text. # If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True #add_function_parentheses = True
...@@ -122,12 +109,6 @@ add_module_names = False ...@@ -122,12 +109,6 @@ add_module_names = False
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx' pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# If true, `todo` and `todoList` produce output, else they produce nothing. # If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True todo_include_todos = True
...@@ -149,175 +130,27 @@ html_theme_options = { ...@@ -149,175 +130,27 @@ html_theme_options = {
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top # The name of an image file (relative to this directory) to place at the top
# of the sidebar. # of the sidebar.
html_logo = 'nifty_logo_black.png' html_logo = 'nifty_logo_black.png'
# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = [] html_static_path = []
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format. # using the given strftime format.
html_last_updated_fmt = '%b %d, %Y' html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated. # If false, no module index is generated.
html_domain_indices = False html_domain_indices = False
# If false, no index is generated. # If false, no index is generated.
html_use_index = False html_use_index = False
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages. # If true, links to the reST sources are added to the pages.
html_show_sourcelink = False html_show_sourcelink = False
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
#html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value
#html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
#html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'NIFTydoc' htmlhelp_basename = 'NIFTydoc'
# -- Options for LaTeX output ---------------------------------------------
#latex_elements = {