Planned maintenance on Wednesday, 2021-01-20, 17:00-18:00. Expect some interruptions during that time

Commit 9c0dde2d authored by Pumpe, Daniel (dpumpe)'s avatar Pumpe, Daniel (dpumpe)

Merge branch 'master' of gitlab.mpcdf.mpg.de:ift/NIFTy

parents 6e2802da 76133243
...@@ -13,7 +13,7 @@ before_script: ...@@ -13,7 +13,7 @@ before_script:
- apt-get update - apt-get update
- > - >
apt-get install -y build-essential python python-pip python-dev git apt-get install -y build-essential python python-pip python-dev git
autoconf gsl-bin libgsl-dev wget python-numpy cython autoconf gsl-bin libgsl-dev wget python-numpy
- pip install --upgrade -r ci/requirements_base.txt - pip install --upgrade -r ci/requirements_base.txt
- chmod +x ci/*.sh - chmod +x ci/*.sh
......
# This Makefile implements common tasks needed by developers
# A list of implemented rules can be obtained by the command "make help"
.DEFAULT_GOAL=build
.PHONY .SILENT : help
help :
echo
echo " Implemented targets:"
echo
echo " build build pypmc for python2 and python3"
echo " buildX build pypmc for pythonX only where X is one of {2,3}"
echo " build-sdist build pypmc from the dist directory (python 2 and 3)"
echo " build-sdistX build pypmc from the dist directory (pythonX, X in {2,3})"
echo " check use nosetests to test pypmc with python 2.7 and 3"
echo " checkX use nosetests to test pypmc with python 2.7 or 3,"
echo " where X is one of {2,3}"
echo " check-fast use nosetests to run only quick tests of pypmc"
echo " using nosetests-2.7 and nosetests3"
echo " check-sdist use nosetests-2.7 and nosetests3 to test the distribution"
echo " generated by 'make sdist'"
echo " check-sdistX use nosetests-2.7 or nosetests3 to test the distribution"
echo " generated by 'make sdist', where X is one of {2,3}"
echo " clean delete compiled and temporary files"
echo " coverage produce and show a code coverage report"
echo " Note: Cython modules cannot be analyzed"
echo " distcheck runs 'check', check-sdist', 'run-examples' and"
echo " opens a browser with the built documentation"
echo " doc build the html documentation using sphinx"
echo " doc-pdf build the pdf documentation using sphinx"
echo " help show this message"
echo " run-examples run all examples using python 2 and 3"
echo " sdist make a source distribution"
echo " show-todos show todo marks in the source code"
echo
.PHONY : clean
clean:
#remove build doc
rm -rf ./doc/_build
#remove .pyc files created by python 2.7
rm -f ./*.pyc
find -P . -name '*.pyc' -delete
#remove .pyc files crated by python 3
rm -rf ./__pycache__
find -P . -name __pycache__ -delete
#remove build folder in root directory
rm -rf ./build
#remove cythonized C source and object files
find -P . -name '*.c' -delete
#remove variational binaries only if command line argument specified
find -P . -name '*.so' -delete
#remove backup files
find -P . -name '*~' -delete
#remove files created by coverage
rm -f .coverage
rm -rf coverage
# remove egg info
rm -rf pypmc.egg-info
# remove downloaded seutptools
rm -f setuptools-3.3.zip
# remove dist/
rm -rf dist
.PHONY : build
build : build2
.PHONY : build2
build2 :
python2 setup.py build_ext --inplace
.PHONY :
check : check2
.PHONY : check2
check2 : build2
@ # run tests
nosetests-2.7 --processes=-1 --process-timeout=60
# run tests in parallel
mpirun -n 2 nosetests-2.7
.PHONY : check-fast
check-fast : build
nosetests-2.7 -a '!slow' --processes=-1 --process-timeout=60
nosetests3 -a '!slow' --processes=-1 --process-timeout=60
.PHONY : .build-system-default
.build-system-default :
python setup.py build_ext --inplace
.PHONY : doc
doc : .build-system-default
cd doc && make html
.PHONY : doc-pdf
doc-pdf : .build-system-default
cd doc; make latexpdf
.PHONY : run-examples
run-examples : build
cd examples ; \
for file in $$(ls) ; do \
echo running $${file} with python2 && \
python2 $${file} && \
echo running $${file} with python3 && \
python3 $${file} && \
\
# execute with mpirun if mpi4py appears in the file \
if grep -Fq 'mpi4py' $${file} ; then \
echo "$${file}" is mpi parallelized && \
echo running $${file} in parallel with python2 && \
mpirun -n 2 python2 $${file} && \
echo running $${file} in parallel with python3 && \
mpirun -n 2 python3 $${file} ; \
fi \
; \
done
.PHONY : sdist
sdist :
python setup.py sdist
.PHONY : build-sdist
build-sdist : build-sdist2 build-sdist3
./dist/pypmc*/NUL : sdist
cd dist && tar xaf *.tar.gz && cd *
.PHONY : build-sdist2
build-sdist2 : ./dist/pypmc*/NUL
cd dist/pypmc* && python2 setup.py build
.PHONY : build-sdist3
build-sdist3 : ./dist/pypmc*/NUL
cd dist/pypmc* && python3 setup.py build
.PHONY : check-sdist
check-sdist : check-sdist2 check-sdist3
.PHONY : check-sdist2
check-sdist2 : build-sdist2
cd dist/*/build/lib*2.7 && \
nosetests-2.7 --processes=-1 --process-timeout=60 && \
mpirun -n 2 nosetests-2.7
.PHONY : check-sdist3
check-sdist3 : build-sdist3
cd dist/*/build/lib*3.* && \
nosetests3 --processes=-1 --process-timeout=60 && \
mpirun -n 2 nosetests3
.PHONY : distcheck
distcheck : check check-sdist doc
@ # execute "run-examples" after all other recipes makes are done
make run-examples
xdg-open link_to_documentation
.PHONY : show-todos
grep_cmd = ack-grep -i --no-html --no-cc [^"au""sphinx.ext."]todo
show-todos :
@ # suppress errors here
@ # note that no todo found is considered as error
$(grep_cmd) doc ; \
$(grep_cmd) pypmc ; \
$(grep_cmd) examples ; echo \
.PHONY : coverage
coverage : .build-system-default
rm -rf coverage
nosetests --with-coverage --cover-package=nifty --cover-html --cover-html-dir=coverage
xdg-open coverage/index.html
Metadata-Version: 1.0
Name: ift_nifty
Version: 1.0.6
Summary: Numerical Information Field Theory
Home-page: http://www.mpa-garching.mpg.de/ift/nifty/
Author: Theo Steininger
Author-email: theos@mpa-garching.mpg.de
License: GPLv3
Description: UNKNOWN
Platform: UNKNOWN
...@@ -15,7 +15,7 @@ Summary ...@@ -15,7 +15,7 @@ Summary
a versatile library designed to enable the development of signal a versatile library designed to enable the development of signal
inference algorithms that operate regardless of the underlying spatial inference algorithms that operate regardless of the underlying spatial
grid and its resolution. Its object-oriented framework is written in grid and its resolution. Its object-oriented framework is written in
Python, although it accesses libraries written in Cython, C++, and C for Python, although it accesses libraries written in C++ and C for
efficiency. efficiency.
NIFTY offers a toolkit that abstracts discretized representations of NIFTY offers a toolkit that abstracts discretized representations of
...@@ -38,25 +38,25 @@ certain grids, **fields** that are defined on spaces, and **operators** ...@@ -38,25 +38,25 @@ certain grids, **fields** that are defined on spaces, and **operators**
that apply to fields. that apply to fields.
- [Spaces](http://www.mpa-garching.mpg.de/ift/nifty/space.html) - [Spaces](http://www.mpa-garching.mpg.de/ift/nifty/space.html)
- `rg_space` - *n*-dimensional regular Euclidean grid - `RGSpace` - *n*-dimensional regular Euclidean grid
- `lm_space` - spherical harmonics - `LMSpace` - spherical harmonics
- `gl_space` - Gauss-Legendre grid on the 2-sphere - `GLSpace` - Gauss-Legendre grid on the 2-sphere
- `hp_space` - [HEALPix](http://sourceforge.net/projects/healpix/) - `HPSpace` - [HEALPix](http://sourceforge.net/projects/healpix/)
grid on the 2-sphere grid on the 2-sphere
- [Fields](http://www.mpa-garching.mpg.de/ift/nifty/field.html) - [Fields](http://www.mpa-garching.mpg.de/ift/nifty/field.html)
- `field` - generic class for (discretized) fields - `Field` - generic class for (discretized) fields
<!-- --> <!-- -->
field.conjugate field.dim field.norm Field.conjugate Field.dim Field.norm
field.dot field.set_val field.weight Field.dot Field.set_val Field.weight
- [Operators](http://www.mpa-garching.mpg.de/ift/nifty/operator.html) - [Operators](http://www.mpa-garching.mpg.de/ift/nifty/operator.html)
- `diagonal_operator` - purely diagonal matrices in a specified - `DiagonalOperator` - purely diagonal matrices in a specified
basis basis
- `projection_operator` - projections onto subsets of a specified - `ProjectionOperator` - projections onto subsets of a specified
basis basis
- `propagator_operator` - information propagator in Wiener filter - `PropagatorOperator` - information propagator in Wiener filter
theory theory
- (and more) - (and more)
- (and more) - (and more)
...@@ -71,16 +71,18 @@ Installation ...@@ -71,16 +71,18 @@ Installation
- [Python](http://www.python.org/) (v2.7.x) - [Python](http://www.python.org/) (v2.7.x)
- [NumPy](http://www.numpy.org/) - [NumPy](http://www.numpy.org/)
- [Cython](http://cython.org/)
### Download ### Download
The latest release is tagged **v1.0.7** and is available as a source The current version of Nifty3 can be obtained by cloning the repository:
package at [](https://gitlab.mpcdf.mpg.de/ift/NIFTy/tags). The current
version can be obtained by cloning the repository:
git clone https://gitlab.mpcdf.mpg.de/ift/NIFTy.git git clone https://gitlab.mpcdf.mpg.de/ift/NIFTy.git
and switching to the "master" branch:
cd NIFTy
git checkout master
### Installation on Ubuntu ### Installation on Ubuntu
This is for you if you want to install NIFTy on your personal computer This is for you if you want to install NIFTy on your personal computer
...@@ -90,53 +92,31 @@ Starting with a fresh Ubuntu installation move to a folder like ...@@ -90,53 +92,31 @@ Starting with a fresh Ubuntu installation move to a folder like
- Install basic packages like python, python-dev, gsl and others: - Install basic packages like python, python-dev, gsl and others:
sudo apt-get install curl git autoconf sudo apt-get install curl git autoconf python-dev python-pip python-numpy
sudo apt-get install python-dev python-pip gsl-bin libgsl0-dev libfreetype6-dev libpng-dev libatlas-base-dev
- Using pip install numpy etc...:
sudo pip install numpy cython
- Install pyHealpix: - Install pyHealpix:
git clone https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git git clone https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git
cd pyHealpix cd pyHealpix
autoreconf -i && ./configure && make -j4 && sudo make install autoreconf -i && ./configure --prefix=$HOME/.local && make -j4 && make install
cd .. cd ..
- Finally, NIFTy: - Finally, NIFTy:
git clone https://gitlab.mpcdf.mpg.de/ift/NIFTy.git git clone https://gitlab.mpcdf.mpg.de/ift/NIFTy.git
cd nifty cd NIFTy
sudo python setup.py install git checkout master
python setup.py install --user
cd .. cd ..
### Installation on a Linux cluster ### Installation on Linux systems in general
This is for you if you want to install NIFTy on a HPC machine or cluster
that is hosted by your university or institute. Most of the dependencies
will most likely already be there, but you won't have superuser
privileges. In this case, instead of:
sudo python setup.py install
use:
python setup.py install --user
or:
python setup.py install --install-lib=/SOMEWHERE Since all the "unconventional" packages (i.e. pyHealpix and NIFTy) listed in the
section above are installed
in the instruction above. This will install the python packages into within the home directory of the user, the installation instructions for these
your local user directory. should also work on any Linux machine where you do not have root access.
In this case you have to ensure with your system administrators that the
For pyHealpix, use: "standard" dependencies (python, numpy, etc.) are installed system-wide.
git clone https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git
cd pyHealpix
autoreconf -i && ./configure --prefix=$HOME/.local && make -j4 && make install
cd ..
### Installation on OS X 10.11 ### Installation on OS X 10.11
...@@ -147,10 +127,9 @@ MacPorts, missing ones need to be installed manually. It may also be ...@@ -147,10 +127,9 @@ MacPorts, missing ones need to be installed manually. It may also be
mentioned that one should only use one package manager, as multiple ones mentioned that one should only use one package manager, as multiple ones
may cause trouble. may cause trouble.
- Install basic packages numpy and cython: - Install numpy:
sudo port install py27-numpy sudo port install py27-numpy
sudo port install py27-cython
- Install pyHealpix: - Install pyHealpix:
...@@ -159,24 +138,18 @@ may cause trouble. ...@@ -159,24 +138,18 @@ may cause trouble.
autoreconf -i && ./configure --prefix=`python-config --prefix` && make -j4 && sudo make install autoreconf -i && ./configure --prefix=`python-config --prefix` && make -j4 && sudo make install
cd .. cd ..
(The third command installs the package system-wide. User-specific
installation would be preferrable, but we haven't found a simple recipe yet
how to determine the installation prefix ...)
- Install NIFTy: - Install NIFTy:
git clone https://gitlab.mpcdf.mpg.de/ift/NIFTy.git git clone https://gitlab.mpcdf.mpg.de/ift/NIFTy.git
cd nifty cd NIFTy
sudo python setup.py install git checkout master
python setup.py install --user
cd .. cd ..
### Installation using pypi
NIFTY can be installed using [PyPI](https://pypi.python.org/pypi) and
**pip** by running the following command:
pip install ift_nifty
Alternatively, a private or user specific installation can be done by:
pip install --user ift_nifty
### 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:
...@@ -224,4 +197,4 @@ The NIFTY package is licensed under the ...@@ -224,4 +197,4 @@ The NIFTY package is licensed under the
[1] Selig et al., "NIFTY - Numerical Information Field Theory - a [1] Selig et al., "NIFTY - Numerical Information Field Theory - a
versatile Python library for signal inference", [A&A, vol. 554, id. versatile Python library for signal inference", [A&A, vol. 554, id.
A26](http://dx.doi.org/10.1051/0004-6361/201321236), 2013; A26](http://dx.doi.org/10.1051/0004-6361/201321236), 2013;
[arXiv:1301.4499](http://www.arxiv.org/abs/1301.4499) [arXiv:1301.4499](http://www.arxiv.org/abs/1301.4499)
\ No newline at end of file
#!/bin/bash #!/bin/bash
git clone -b mpi https://github.com/ultimanet/pyFFTW.git git clone -b mpi https://github.com/fredros/pyFFTW.git
cd pyFFTW/ cd pyFFTW/
CC=mpicc python setup.py build_ext install CC=mpicc python setup.py build_ext install
cd .. cd ..
......
numpy numpy
cython
mpi4py mpi4py
matplotlib matplotlib
plotly plotly
......
...@@ -87,7 +87,7 @@ class DomainObject(Versionable, Loggable, object): ...@@ -87,7 +87,7 @@ class DomainObject(Versionable, Loggable, object):
@abc.abstractproperty @abc.abstractproperty
def shape(self): def shape(self):
""" Returns the shape of the underlying array-like object. """ The domain-object's shape contribution to the underlying array.
Returns Returns
------- -------
......
This diff is collapsed.
...@@ -24,7 +24,7 @@ from diagonal_operator import DiagonalOperator ...@@ -24,7 +24,7 @@ from diagonal_operator import DiagonalOperator
from endomorphic_operator import EndomorphicOperator from endomorphic_operator import EndomorphicOperator
from smoothing_operator import SmoothingOperator from smoothing_operator import *
from fft_operator import * from fft_operator import *
......
...@@ -75,7 +75,8 @@ class LinearOperator(Loggable, object): ...@@ -75,7 +75,8 @@ class LinearOperator(Loggable, object):
def __init__(self, default_spaces=None): def __init__(self, default_spaces=None):
self.default_spaces = default_spaces self.default_spaces = default_spaces
def _parse_domain(self, domain): @staticmethod
def _parse_domain(domain):
return utilities.parse_domain(domain) return utilities.parse_domain(domain)
@abc.abstractproperty @abc.abstractproperty
......
...@@ -6,6 +6,7 @@ from nifty.operators.smoothing_operator import SmoothingOperator ...@@ -6,6 +6,7 @@ from nifty.operators.smoothing_operator import SmoothingOperator
from nifty.operators.composed_operator import ComposedOperator from nifty.operators.composed_operator import ComposedOperator
from nifty.operators.diagonal_operator import DiagonalOperator from nifty.operators.diagonal_operator import DiagonalOperator
class ResponseOperator(LinearOperator): class ResponseOperator(LinearOperator):
""" NIFTy ResponseOperator (example) """ NIFTy ResponseOperator (example)
......
...@@ -16,4 +16,4 @@ ...@@ -16,4 +16,4 @@
# 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/>.
from smoothing_operator import SmoothingOperator from .smoothing_operator import SmoothingOperator
# -*- coding: utf8 -*-
import numpy as np
from d2o import STRATEGIES
from .smoothing_operator import SmoothingOperator
class DirectSmoothingOperator(SmoothingOperator):
def __init__(self, domain, sigma, log_distances=False,
default_spaces=None):
super(DirectSmoothingOperator, self).__init__(domain,
sigma,
log_distances,
default_spaces)
self.effective_smoothing_width = 3.01
def _precompute(self, x, sigma, dxmax=None):
""" Does precomputations for Gaussian smoothing on a 1D irregular grid.
Parameters
----------
x: 1D floating point array or list containing the individual grid
positions. Points must be given in ascending order.
sigma: The sigma of the Gaussian with which the function living on x
should be smoothed, in the same units as x.
dxmax: (optional) The maximum distance up to which smoothing is
performed, in the same units as x. Default is 3.01*sigma.
Returns
-------
ibegin: integer array of the same size as x
ibegin[i] is the minimum grid index to consider when computing the
smoothed value at grid index i
nval: integer array of the same size as x
nval[i] is the number of indices to consider when computing the
smoothed value at grid index i.
wgt: list with the same number of entries as x
wgt[i] is an array with nval[i] entries containing the
normalized smoothing weights.
"""
if dxmax is None:
dxmax = self.effective_smoothing_width*sigma
x = np.asarray(x)
ibegin = np.searchsorted(x, x-dxmax)
nval = np.searchsorted(x, x+dxmax) - ibegin
wgt = []
expfac = 1. / (2. * sigma*sigma)
for i in range(x.size):
t = x[ibegin[i]:ibegin[i]+nval[i]]-x[i]
t = np.exp(-t*t*expfac)
t *= 1./np.sum(t)
wgt.append(t)
return ibegin, nval, wgt
def _apply_kernel_along_array(self, power, startindex, endindex,
distances, smooth_length, smoothing_width,
ibegin, nval, wgt):
if smooth_length == 0.0:
return power[startindex:endindex]
p_smooth = np.zeros(endindex-startindex, dtype=power.dtype)
for i in xrange(startindex, endindex):
imin = max(startindex, ibegin[i])
imax = min(endindex, ibegin[i]+nval[i])
p_smooth[imin:imax] += (power[i] *
wgt[i][imin-ibegin[i]:imax-imin+ibegin[i]])
return p_smooth
def _apply_along_axis(self, axis, arr, startindex, endindex, distances,
smooth_length, smoothing_width):
nd = arr.ndim
if axis < 0:
axis += nd
if (axis >= nd):
raise ValueError(
"axis must be less than arr.ndim; axis=%d, rank=%d."
% (axis, nd))
ibegin, nval, wgt = self._precompute(
distances, smooth_length, smooth_length*smoothing_width)
ind = np.zeros(nd-1, dtype=np.int)
i = np.zeros(nd, dtype=object)
shape = arr.shape
indlist = np.asarray(range(nd))
indlist = np.delete(indlist, axis)
i[axis] = slice(None, None)
outshape = np.asarray(shape).take(indlist)
i.put(indlist, ind)
Ntot = np.product(outshape)
holdshape = outshape
slicedArr = arr[tuple(i.tolist())]
res = self._apply_kernel_along_array(
slicedArr, startindex, endindex, distances,
smooth_length, smoothing_width, ibegin, nval, wgt)
outshape = np.asarray(arr.shape)
outshape[axis] = endindex - startindex
outarr = np.zeros(outshape, dtype=arr.dtype)
outarr[tuple(i.tolist())] = res
k = 1
while k < Ntot:
# increment the index
ind[nd-1] += 1
n = -1
while (ind[n] >= holdshape[n]) and (n > (1-nd)):
ind[n-1] += 1
ind[n] = 0
n -= 1
i.put(indlist, ind)
slicedArr = arr[tuple(i.tolist())]
res = self._apply_kernel_along_array(
slicedArr, startindex, endindex, distances,
smooth_length, smoothing_width, ibegin, nval, wgt)
outarr[tuple(i.tolist())] = res