diff --git a/README.md b/README.md index 9dec93902b846693af648acc44f4ac76d2b4df36..611f51e2fa6cd8dbd674ac4366c665f1f231a53d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Summary ### Description -**NIFTY**, "**N**umerical **I**nformation **F**ield **T**heor**y**", is +**NIFTY**, "**N**umerical **I**nformation **F**ield **T**heor<strong>y</strong>", is a versatile library designed to enable the development of signal inference algorithms that operate regardless of the underlying spatial grid and its resolution. Its object-oriented framework is written in @@ -87,21 +87,17 @@ Starting with a fresh Ubuntu installation move to a folder like - Install basic packages like python, python-dev, gsl and others: - sudo apt-get install curl git autoconf python-dev python-pip python-numpy + sudo apt-get install curl git autoconf libtool python-dev python-pip python-numpy - Install pyHealpix: git clone https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git - cd pyHealpix - autoreconf -i && ./configure --prefix=$HOME/.local --enable-openmp --enable-native-optimizations && make -j4 && make install - cd .. + (cd pyHealpix && autoreconf -i && ./configure --prefix=$HOME/.local --enable-openmp --enable-native-optimizations && make -j4 install) - Finally, NIFTy: git clone https://gitlab.mpcdf.mpg.de/ift/NIFTy.git - cd NIFTy - python setup.py install --user - cd .. + (cd NIFTy && python setup.py install --user) ### Installation on Linux systems in general @@ -139,16 +135,13 @@ may cause trouble. - Install NIFTy: git clone https://gitlab.mpcdf.mpg.de/ift/NIFTy.git - cd NIFTy - python setup.py install --user - cd .. + (cd NIFTy && python setup.py install --user) ### Running the tests In oder to run the tests one needs two additional packages: - pip install nose - pip install parameterized + pip install nose parameterized Afterwards the tests (including a coverage report) are run using the following command in the repository root: diff --git a/ci/install_basics.sh b/ci/install_basics.sh index 46e446ce5299080f10d78c3339c488f2d3930728..796ba27fece74fb5cc00c72702abdfc5997e0f69 100644 --- a/ci/install_basics.sh +++ b/ci/install_basics.sh @@ -1,3 +1,3 @@ #!/bin/bash -apt-get install -y build-essential python python-pip python-dev git autoconf gsl-bin libgsl-dev wget +apt-get install -y build-essential python python-pip python-dev git autoconf libtool gsl-bin libgsl-dev wget diff --git a/ci/install_h5py.sh b/ci/install_h5py.sh index 4649934d4559245fa4ee9a25898f281cceb9bd6b..6702ca879bd5710fc269319b067c598ea0bbff53 100644 --- a/ci/install_h5py.sh +++ b/ci/install_h5py.sh @@ -1,9 +1,4 @@ #!/bin/bash apt-get install -y libhdf5-10 libhdf5-dev libhdf5-openmpi-10 libhdf5-openmpi-dev hdf5-tools - -export CC=mpicc -export HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/openmpi -export HDF5_MPI="ON" - -pip install --no-binary=h5py h5py +CC=mpicc HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/openmpi HDF5_MPI="ON" pip install --no-binary=h5py h5py diff --git a/ci/install_mpi4py.sh b/ci/install_mpi4py.sh index d53b536e82b3da88eb4a12362544eb57a2c4b56b..a2f71dca1584c4a95799a1b827361ab6f0b63782 100644 --- a/ci/install_mpi4py.sh +++ b/ci/install_mpi4py.sh @@ -1,4 +1,4 @@ #!/bin/bash apt-get install -y openmpi-bin libopenmpi-dev -pip install mpi4py \ No newline at end of file +pip install mpi4py diff --git a/ci/install_pyHealpix.sh b/ci/install_pyHealpix.sh index 504f9123ff63eb5c9159ebcddc9b43cd06264890..914d0c1d1b7dba1694b5a6d08e446fd576e9f9ed 100644 --- a/ci/install_pyHealpix.sh +++ b/ci/install_pyHealpix.sh @@ -1,7 +1,5 @@ #!/bin/bash git clone https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git -cd pyHealpix -autoreconf -i && ./configure && make -j4 install -cd .. +(cd pyHealpix && autoreconf -i && ./configure --enable-openmp --enable-native-optimizations && make -j4 install) rm -rf pyHealpix diff --git a/ci/install_pyfftw.sh b/ci/install_pyfftw.sh index 670048030bede61ddf1dbcc561a9083876c17f3b..e0c120baf24e0c85671719977cd4b8b73fa853e5 100644 --- a/ci/install_pyfftw.sh +++ b/ci/install_pyfftw.sh @@ -3,7 +3,5 @@ apt-get install -y libatlas-base-dev libfftw3-bin libfftw3-dev libfftw3-double3 libfftw3-long3 libfftw3-mpi-dev libfftw3-mpi3 libfftw3-quad3 libfftw3-single3 git clone -b mpi https://github.com/fredros/pyFFTW.git -cd pyFFTW/ -CC=mpicc python setup.py build_ext install -cd .. -rm -r pyFFTW +(cd pyFFTW && CC=mpicc python setup.py build_ext install) +rm -rf pyFFTW diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..53bfc172ec19088227436bd75c551eae5d9e321e --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,216 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = build + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source + +.PHONY: help +help: + @echo "Please use \`make <target>' where <target> is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " applehelp to make an Apple Help Book" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + @echo " coverage to run coverage check of the documentation (if enabled)" + +.PHONY: clean +clean: + rm -rf $(BUILDDIR)/* + +.PHONY: html +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +.PHONY: dirhtml +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +.PHONY: singlehtml +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +.PHONY: pickle +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +.PHONY: json +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +.PHONY: htmlhelp +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +.PHONY: qthelp +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/NIFTY.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/NIFTY.qhc" + +.PHONY: applehelp +applehelp: + $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp + @echo + @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." + @echo "N.B. You won't be able to view it unless you put it in" \ + "~/Library/Documentation/Help or install it in your application" \ + "bundle." + +.PHONY: devhelp +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/NIFTY" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/NIFTY" + @echo "# devhelp" + +.PHONY: epub +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +.PHONY: latex +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +.PHONY: latexpdf +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +.PHONY: latexpdfja +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +.PHONY: text +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +.PHONY: man +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +.PHONY: texinfo +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +.PHONY: info +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +.PHONY: gettext +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +.PHONY: changes +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +.PHONY: linkcheck +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +.PHONY: doctest +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +.PHONY: coverage +coverage: + $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage + @echo "Testing of coverage in the sources finished, look at the " \ + "results in $(BUILDDIR)/coverage/python.txt." + +.PHONY: xml +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +.PHONY: pseudoxml +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/docs/source/composed_operator.rst b/docs/source/composed_operator.rst new file mode 100644 index 0000000000000000000000000000000000000000..db744c386f862aec6c02f9b9c5c0b12a50aac3c4 --- /dev/null +++ b/docs/source/composed_operator.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``ComposedOperator`` class -- A possibility to combine several operators +............................................................................ + +.. autoclass:: ComposedOperator + :show-inheritance: + :members: diff --git a/docs/source/conf.py b/docs/source/conf.py index a68fcf8d3bacaebb26d759b94dc5cb87a09b6c79..32542089412f030525e0d6cf7e1b3eaeb315e1f0 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -325,4 +325,4 @@ texinfo_documents = [ # Example configuration for intersphinx: refer to the Python standard library. -#intersphinx_mapping = {'https://docs.python.org/': None} +#intersphinx_mapping = {'https://docs.python.org/': None} \ No newline at end of file diff --git a/docs/source/conjugate_gradient.rst b/docs/source/conjugate_gradient.rst new file mode 100644 index 0000000000000000000000000000000000000000..375796395d43fc569d3d1be8ed005fb07697bc41 --- /dev/null +++ b/docs/source/conjugate_gradient.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``ConjugateGradient`` class -- Minimization routine +....................................................... + +.. autoclass:: ConjugateGradient + :show-inheritance: + :members: diff --git a/docs/source/descent_minimizer.rst b/docs/source/descent_minimizer.rst new file mode 100644 index 0000000000000000000000000000000000000000..29363c6383a67707e2c50ea1871cce292225b608 --- /dev/null +++ b/docs/source/descent_minimizer.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``DescentMinimizer`` class -- The Base class for minimizers +............................................................... + +.. autoclass:: DescentMinimizer + :show-inheritance: + :members: diff --git a/docs/source/diagonal_operator.rst b/docs/source/diagonal_operator.rst new file mode 100644 index 0000000000000000000000000000000000000000..0dc633e47396c4349809c813f9c7d7cbe6e737ab --- /dev/null +++ b/docs/source/diagonal_operator.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``DiagonalOperator`` class -- ... +..................................... + +.. autoclass:: DiagonalOperator + :show-inheritance: + :members: diff --git a/docs/source/endomorphic_operator.rst b/docs/source/endomorphic_operator.rst new file mode 100644 index 0000000000000000000000000000000000000000..facb826d54c6019ccbda28df5c0261ea4e898854 --- /dev/null +++ b/docs/source/endomorphic_operator.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``EndomorphicOperator`` class -- ... +........................................ + +.. autoclass:: EndomorphicOperator + :show-inheritance: + :members: diff --git a/docs/source/fft_operator.rst b/docs/source/fft_operator.rst new file mode 100644 index 0000000000000000000000000000000000000000..9bc6dc205473981468cfb27a46d0b8d3381c54ef --- /dev/null +++ b/docs/source/fft_operator.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``FFTOperator`` class -- Fourier Transformations +.................................................... + +.. autoclass:: FFTOperator + :show-inheritance: + :members: diff --git a/docs/source/field.rst b/docs/source/field.rst index eb70e5e514586f1bc7274b54112bb24f08dd8d95..c753c8af01f62c25f7d2478e32aef209719b135f 100644 --- a/docs/source/field.rst +++ b/docs/source/field.rst @@ -10,4 +10,3 @@ In NIFTY, Fields are used to store data arrays and carry all the needed metainfo .. autoclass:: Field :show-inheritance: :members: - diff --git a/docs/source/gl_space.rst b/docs/source/gl_space.rst new file mode 100644 index 0000000000000000000000000000000000000000..9b1901c3725f39bc26338410ff06b949156f3f7a --- /dev/null +++ b/docs/source/gl_space.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``GLSpace`` class -- Gauss-Legendre pixelization of the sphere +.................................................................. + +.. autoclass:: GLSpace + :show-inheritance: + :members: diff --git a/docs/source/gllm_transformation.rst b/docs/source/gllm_transformation.rst new file mode 100644 index 0000000000000000000000000000000000000000..8de4a0b3bbd7ee15f7f2e1d823310ebc0b678642 --- /dev/null +++ b/docs/source/gllm_transformation.rst @@ -0,0 +1,9 @@ +.. currentmodule:: nifty + +The ``GLLMTransformation`` class -- A transformation routine +............................................................ + + +.. autoclass:: GLLMTransformation + :show-inheritance: + :members: diff --git a/docs/source/hp_space.rst b/docs/source/hp_space.rst new file mode 100644 index 0000000000000000000000000000000000000000..f53f20d8b767a2f9525e654b92b7462ad265e12c --- /dev/null +++ b/docs/source/hp_space.rst @@ -0,0 +1,9 @@ +.. currentmodule:: nifty + +The ``HPSpace`` class -- HEALPix discretization of the sphere +............................................................. + + +.. autoclass:: HPSpace + :show-inheritance: + :members: diff --git a/docs/source/hplm_transformation.rst b/docs/source/hplm_transformation.rst new file mode 100644 index 0000000000000000000000000000000000000000..7678bc8cab6ca6866f2290f71520a8760fc6e41c --- /dev/null +++ b/docs/source/hplm_transformation.rst @@ -0,0 +1,9 @@ +.. currentmodule:: nifty + +The ``HPLMTransformation`` class -- A transformation routine +............................................................ + + +.. autoclass:: HPLMTransformation + :show-inheritance: + :members: diff --git a/docs/source/index.rst b/docs/source/index.rst index f65d7a9e109810300c858e3bb9c2a8e8355bfeaf..31daeb34fcb533b42c1fd4dcdd6d7b2831c67c41 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -38,4 +38,3 @@ Indices and tables * :ref:`genindex` * :any:`Module Index <mod/modules>` * :ref:`search` - diff --git a/docs/source/invertible_operator_mixin.rst b/docs/source/invertible_operator_mixin.rst new file mode 100644 index 0000000000000000000000000000000000000000..40d7392bd30f5d395a323d1bb8a131af384dcc73 --- /dev/null +++ b/docs/source/invertible_operator_mixin.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``InvertibleOperatorMixin`` class -- ... +............................................ + +.. autoclass:: InvertibleOperatorMixin + :show-inheritance: + :members: diff --git a/docs/source/lm_space.rst b/docs/source/lm_space.rst new file mode 100644 index 0000000000000000000000000000000000000000..1a695e55b618fb6aad72bc80b073b6959184067d --- /dev/null +++ b/docs/source/lm_space.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``LMSpace`` class -- Spherical Harmonics components +....................................................... + +.. autoclass:: LMSpace + :show-inheritance: + :members: diff --git a/docs/source/lmgl_transformation.rst b/docs/source/lmgl_transformation.rst new file mode 100644 index 0000000000000000000000000000000000000000..fca87f2e75132476fcf76160ab94094a276ea930 --- /dev/null +++ b/docs/source/lmgl_transformation.rst @@ -0,0 +1,9 @@ +.. currentmodule:: nifty + +The ``LMGLTransformation`` class -- A transformation routine +............................................................ + + +.. autoclass:: LMGLTransformation + :show-inheritance: + :members: diff --git a/docs/source/lmhp_transformation.rst b/docs/source/lmhp_transformation.rst new file mode 100644 index 0000000000000000000000000000000000000000..069d2449e24973f4fd0f22edbcbae87571b18e6d --- /dev/null +++ b/docs/source/lmhp_transformation.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``LMHPTransformation`` class -- A transformation routine +............................................................ + +.. autoclass:: LMHPTransformation + :show-inheritance: + :members: diff --git a/docs/source/minimization.rst b/docs/source/minimization.rst new file mode 100644 index 0000000000000000000000000000000000000000..f581fce0a33265a068c33678c5a0a601f32dffc3 --- /dev/null +++ b/docs/source/minimization.rst @@ -0,0 +1,11 @@ +Minimization +------------ +NIFTY provides several minimization routines. + + +.. toctree:: + :maxdepth: 1 + + conjugate_gradient + descent_minimizer + diff --git a/docs/source/operator.rst b/docs/source/operator.rst new file mode 100644 index 0000000000000000000000000000000000000000..211eb4f2d7be7661c6f56ad0d5c0afb5ed407b10 --- /dev/null +++ b/docs/source/operator.rst @@ -0,0 +1,45 @@ +Operators +========= +Operators perform some operation on a given field. In practice an operator can +take the form of an explicit matrix (e.g. stored in a Numpy array) or it may be +implicitly defined as a function (e.g. an FFT operation would not be encoded in +a matrix, but performed using an FFT routine). NIFTY includes a framework for +handling arbitrary operators, and basic methods for manipulating these +operators. Common functions like taking traces and extracting diagonals are +provided. + +In order to have a blueprint for operators capable of handling fields, any +application of operators is split into a general and a concrete part. The +general part comprises the correct involvement of normalizations and +transformations, necessary for any operator type, while the concrete part is +unique for each operator subclass. In analogy to the field class, any operator +instance has a set of properties that specify its domain and target as well as +some additional flags. + +Operator classes +---------------- +NIFTY provides a base class for defining operators, as well as several pre-implemented operator types that are very often needed for signal inference +algorithms. + +.. toctree:: + :maxdepth: 1 + + diagonal_operator + fft_operator + composed_operator + response_operator + smoothing_operator + projection_operator + propagator_operator + endomorphic_operator + invertible_operator_mixin + transformations + +.. currentmodule:: nifty + +The ``LinearOperator`` class -- The base Operator Object +-------------------------------------------------------- + +.. autoclass:: LinearOperator + :show-inheritance: + :members: diff --git a/docs/source/power_space.rst b/docs/source/power_space.rst new file mode 100644 index 0000000000000000000000000000000000000000..1ed47f4a9d07b14b50378c909579e503753c0802 --- /dev/null +++ b/docs/source/power_space.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``PowerSpace`` class -- The natural space underlying power-spectra +....................................................................... + +.. autoclass:: PowerSpace + :show-inheritance: + :members: diff --git a/docs/source/projection_operator.rst b/docs/source/projection_operator.rst new file mode 100644 index 0000000000000000000000000000000000000000..761f4373e601bb6f8b1982bba86aeb7a95c3d332 --- /dev/null +++ b/docs/source/projection_operator.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``ProjectionOperator`` class -- ... +....................................... + +.. autoclass:: ProjectionOperator + :show-inheritance: + :members: diff --git a/docs/source/propagator_operator.rst b/docs/source/propagator_operator.rst new file mode 100644 index 0000000000000000000000000000000000000000..28fcbcf9a20cfcb933ea366a2dbd5e3125e1fd18 --- /dev/null +++ b/docs/source/propagator_operator.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``PropagatorOperator`` class -- ... +....................................... + +.. autoclass:: PropagatorOperator + :show-inheritance: + :members: diff --git a/docs/source/response_operator.rst b/docs/source/response_operator.rst new file mode 100644 index 0000000000000000000000000000000000000000..4cfc9fed1fa7b80ccef2befdcc8bec316cdabd50 --- /dev/null +++ b/docs/source/response_operator.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``ResponseOperator`` class -- A possible response implementation +.................................................................... + +.. autoclass:: ResponseOperator + :show-inheritance: + :members: diff --git a/docs/source/rg_space.rst b/docs/source/rg_space.rst new file mode 100644 index 0000000000000000000000000000000000000000..4f4b1390202299dfbeaad39bdefb763c879101aa --- /dev/null +++ b/docs/source/rg_space.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``RGSpace`` class -- Regular Cartesian grids +................................................ + +.. autoclass:: RGSpace + :show-inheritance: + :members: diff --git a/docs/source/rgrg_transformation.rst b/docs/source/rgrg_transformation.rst new file mode 100644 index 0000000000000000000000000000000000000000..7a1aa4020c295f6ea2051223e7520269620e6f34 --- /dev/null +++ b/docs/source/rgrg_transformation.rst @@ -0,0 +1,9 @@ +.. currentmodule:: nifty + +The ``RGRGTransformation`` class -- A transformation routine +............................................................ + + +.. autoclass:: RGRGTransformation + :show-inheritance: + :members: diff --git a/docs/source/smoothing_operator.rst b/docs/source/smoothing_operator.rst new file mode 100644 index 0000000000000000000000000000000000000000..39f8a403038b0042301c41f16ff2d434b400eb47 --- /dev/null +++ b/docs/source/smoothing_operator.rst @@ -0,0 +1,8 @@ +.. currentmodule:: nifty + +The ``SmoothingOperator`` class -- Smoothing fields +................................................... + +.. autoclass:: SmoothingOperator + :show-inheritance: + :members: diff --git a/docs/source/spaces.rst b/docs/source/spaces.rst new file mode 100644 index 0000000000000000000000000000000000000000..43c0c61bdc3929a478269204b40bb89a7bc11ad7 --- /dev/null +++ b/docs/source/spaces.rst @@ -0,0 +1,30 @@ +Spaces +====== +The :py:class:`Space` classes of NIFTY represent geometrical spaces approximated by grids in the computer environment. Each subclass of the base class corresponds to a specific grid type and replaces some of the inherited methods with its own methods that are unique to the respective grid. This framework ensures an abstract handling of spaces independent of the underlying geometrical grid and the grid's resolution. + +Each instance of a :py:class:`Space` needs to capture all structural and dimensional specifics of the grid and all computationally relevant quantities such as the data type of associated field values. These parameters are stored as properties of an instance of the class at its initialization, and they do not need to be accessed explicitly by the user thereafter. This prevents the writing of grid or resolution dependent code. + +Spatial symmetries of a system can be exploited by corresponding coordinate transformations. Often, transformations from one basis to its harmonic counterpart can greatly reduce the computational complexity of algorithms. The harmonic basis is defined by the eigenbasis of the Laplace operator; e.g., for a flat position space it is the Fourier basis. This conjugation of bases is implemented in NIFTY by distinguishing conjugate space classes, which can be obtained by the instance method *get_codomain* (and checked for by *check_codomain*). Moreover, transformations between conjugate spaces are performed automatically if required. + + +Space classes +------------- +Next to the generic :py:class:`Space` class, NIFTY has implementations of five subclasses, representing specific geometrical spaces and their discretizations. + +.. toctree:: + :maxdepth: 1 + + rg_space + hp_space + gl_space + lm_space + power_space + +.. currentmodule:: nifty + +The ``Space`` class -- The base Space object +-------------------------------------------- + +.. autoclass:: Space + :show-inheritance: + :members: diff --git a/docs/source/transformations.rst b/docs/source/transformations.rst new file mode 100644 index 0000000000000000000000000000000000000000..c5e884a343e6e8a2db1e7edd7d5165758aec8744 --- /dev/null +++ b/docs/source/transformations.rst @@ -0,0 +1,13 @@ +Transformations +--------------- +NIFTY provides transformations + +.. toctree:: + :maxdepth: 1 + + rgrg_transformation + gllm_transformation + hplm_transformation + lmgl_transformation + lmhp_transformation + diff --git a/nifty/__init__.py b/nifty/__init__.py index 2c1a96d2f8ef31c13bd83c1be971d081d77768e6..572f0f82d3c8c0473d728012ce10c008186fe6c5 100644 --- a/nifty/__init__.py +++ b/nifty/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from __future__ import division diff --git a/nifty/basic_arithmetics.py b/nifty/basic_arithmetics.py index 30735f6b65314ed42fa0c8ad3972cafbeba73e95..c17f2cd110fd1f9b14407cd73a1fc31669ba7b7b 100644 --- a/nifty/basic_arithmetics.py +++ b/nifty/basic_arithmetics.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np from d2o import distributed_data_object diff --git a/nifty/config/__init__.py b/nifty/config/__init__.py index d39be63fa4d64189614dff3d1f2214f3b32da8f2..a4432e9dde79317b9bc80da7f32da8dae096b09d 100644 --- a/nifty/config/__init__.py +++ b/nifty/config/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from nifty_config import dependency_injector,\ diff --git a/nifty/config/d2o_config.py b/nifty/config/d2o_config.py index 414eb7b5fa4ec0abd24e1c11429d139813618f86..c5d3385d6a7dc64ca85edf8830c1b55c1c5a36d3 100644 --- a/nifty/config/d2o_config.py +++ b/nifty/config/d2o_config.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import os diff --git a/nifty/config/nifty_config.py b/nifty/config/nifty_config.py index 373da5418109b863df0a05326342bb94ae92fb81..fc71a5ccd4ffd4e5d0f36c16e5d59c3680114cfc 100644 --- a/nifty/config/nifty_config.py +++ b/nifty/config/nifty_config.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import matplotlib_init @@ -29,9 +29,7 @@ __all__ = ['dependency_injector', 'nifty_configuration'] dependency_injector = keepers.DependencyInjector( [('mpi4py.MPI', 'MPI'), 'pyHealpix', - 'plotly', - 'pylab', - 'healpy']) + 'plotly']) dependency_injector.register('pyfftw', lambda z: hasattr(z, 'FFTW_MPI')) diff --git a/nifty/domain_object.py b/nifty/domain_object.py index 3a04fae72006ec2ce2c1ad8e28fd6a20d278d4ad..5354f80320f19adbc50d5fe67a13223c2eeb5485 100644 --- a/nifty/domain_object.py +++ b/nifty/domain_object.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import abc from nifty.nifty_meta import NiftyMeta @@ -45,6 +45,10 @@ class DomainObject(Versionable, Loggable, object): # _global_id is used in the Versioning module from keepers self._ignore_for_hash = ['_global_id'] + @abc.abstractmethod + def __repr__(self): + raise NotImplementedError + def __hash__(self): # Extract the identifying parts from the vars(self) dict. result_hash = 0 diff --git a/nifty/energies/__init__.py b/nifty/energies/__init__.py index 6353111fe39996f34bc9b3af9cc87cef29b3a2d3..0ac10a4dd67b6c24d79edc7092c54bc756c8426b 100644 --- a/nifty/energies/__init__.py +++ b/nifty/energies/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from energy import Energy from line_energy import LineEnergy diff --git a/nifty/energies/energy.py b/nifty/energies/energy.py index 851f201e76cf884481f307083809864eaf0486e0..d5d8b2fd3308d39af516abb6ffdeb35636dff200 100644 --- a/nifty/energies/energy.py +++ b/nifty/energies/energy.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from nifty.nifty_meta import NiftyMeta diff --git a/nifty/energies/line_energy.py b/nifty/energies/line_energy.py index 27f09399fca9d381c842b77f4756cbf319b8622b..dcefbdc23819e9614b4dd96669db02e823077fb5 100644 --- a/nifty/energies/line_energy.py +++ b/nifty/energies/line_energy.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from .energy import Energy diff --git a/nifty/energies/memoization.py b/nifty/energies/memoization.py index f2635751d1aa42e31f72e1a327313789648e2b97..7142dab8291f4e41ad7fc2951a1f40f26ca15525 100644 --- a/nifty/energies/memoization.py +++ b/nifty/energies/memoization.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. def memo(f): diff --git a/nifty/field.py b/nifty/field.py index 2f5a4bbf68b735fe30d5ba6d3609ecdf32bb0b6e..e30aa75824dd104ea67152198cf568fc2d260b4b 100644 --- a/nifty/field.py +++ b/nifty/field.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from __future__ import division @@ -218,7 +218,7 @@ class Field(Loggable, Versionable, object): See Also -------- - power_synthesise + power_synthesize """ @@ -270,12 +270,13 @@ class Field(Loggable, Versionable, object): def power_analyze(self, spaces=None, logarithmic=False, nbin=None, binbounds=None, decompose_power=True): - """ Computes the powerspectrum for a subspace of the Field. + """ Computes the square root power spectrum for a subspace of `self`. Creates a PowerSpace for the space addressed by `spaces` with the given binning and computes the power spectrum as a Field over this PowerSpace. This can only be done if the subspace to be analyzed is a - harmonic space. + harmonic space. The resulting field has the same units as the initial + field, corresponding to the square root of the power spectrum. Parameters ---------- @@ -385,6 +386,7 @@ class Field(Loggable, Versionable, object): for part in [hermitian_part, anti_hermitian_part]] power_spectrum = hermitian_power + 1j * anti_hermitian_power + else: power_spectrum = self._calculate_power_spectrum( x=self.val, @@ -395,11 +397,7 @@ class Field(Loggable, Versionable, object): # create the result field and put power_spectrum into it result_domain = list(self.domain) result_domain[space_index] = power_domain - - if decompose_power: - result_dtype = np.complex - else: - result_dtype = np.float + result_dtype = power_spectrum.dtype result_field = self.copy_empty( domain=result_domain, @@ -456,14 +454,10 @@ class Field(Loggable, Versionable, object): def power_synthesize(self, spaces=None, real_power=True, real_signal=True, mean=None, std=None): - """ Converts a power spectrum into a random field realization. - - This method draws a Gaussian random field in the harmic partner domain - of a PowerSpace. + """ Yields a sampled field with `self`**2 as its power spectrum. - Notes - ----- - For this the spaces specified by `spaces` must be a PowerSpaces. + This method draws a Gaussian random field in the harmonic partner + domain of this fields domains, using this field as power spectrum. Parameters ---------- @@ -484,7 +478,6 @@ class Field(Loggable, Versionable, object): std : float *optional* The standard deviation of the Gaussian noise field which is used for the Field synthetization (default : None). - {default : None} if std==None : std will be set to 1 Returns @@ -493,10 +486,20 @@ class Field(Loggable, Versionable, object): The output object. A random field created with the power spectrum stored in the `spaces` in `self`. + Notes + ----- + For this the spaces specified by `spaces` must be a PowerSpace. + This expects this field to be the square root of a power spectrum, i.e. + to have the unit of the field to be sampled. + See Also -------- power_analyze + Raises + ------ + ValueError : If domain specified by `spaces` is not a PowerSpace. + """ # check if the `spaces` input is valid @@ -579,39 +582,57 @@ class Field(Loggable, Versionable, object): def _hermitian_decomposition(domain, val, spaces, domain_axes): # hermitianize for the first space (h, a) = domain[spaces[0]].hermitian_decomposition( - val, - domain_axes[spaces[0]]) + val, + domain_axes[spaces[0]], + preserve_gaussian_variance=True) # hermitianize all remaining spaces using the iterative formula for space in xrange(1, len(spaces)): - (hh, ha) = \ - domain[space].hermitian_decomposition(h, domain_axes[space]) - (ah, aa) = \ - domain[space].hermitian_decomposition(a, domain_axes[space]) + (hh, ha) = domain[space].hermitian_decomposition( + h, + domain_axes[space], + preserve_gaussian_variance=True) + (ah, aa) = domain[space].hermitian_decomposition( + a, + domain_axes[space], + preserve_gaussian_variance=True) c = (hh - ha - ah + aa).conjugate() h = (val + c)/2. a = (val - c)/2. # correct variance - fixed_points = [domain[i].hermitian_fixed_points() for i in spaces] - # check if there was at least one flipping during hermitianization - flipped_Q = np.any([fp is not None for fp in fixed_points]) - # if the array got flipped, correct the variance - if flipped_Q: - h *= np.sqrt(2) - a *= np.sqrt(2) - fixed_points = [[fp] if fp is None else fp for fp in fixed_points] - for product_point in itertools.product(*fixed_points): - slice_object = np.array((slice(None), )*len(val.shape), - dtype=np.object) - for i, sp in enumerate(spaces): - point_component = product_point[i] - if point_component is None: - point_component = slice(None) - slice_object[list(domain_axes[sp])] = point_component - - slice_object = tuple(slice_object) - h[slice_object] /= np.sqrt(2) - a[slice_object] /= np.sqrt(2) + + # in principle one must not correct the variance for the fixed + # points of the hermitianization. However, for a complex field + # the input field loses half of its power at its fixed points + # in the `hermitian` part. Hence, here a factor of sqrt(2) is + # also necessary! + # => The hermitianization can be done on a space level since either + # nothing must be done (LMSpace) or ALL points need a factor of sqrt(2) + # => use the preserve_gaussian_variance flag in the + # hermitian_decomposition method above. + + # This code is for educational purposes: +# fixed_points = [domain[i].hermitian_fixed_points() for i in spaces] +# # check if there was at least one flipping during hermitianization +# flipped_Q = np.any([fp is not None for fp in fixed_points]) +# # if the array got flipped, correct the variance +# if flipped_Q: +# h *= np.sqrt(2) +# a *= np.sqrt(2) +# +# fixed_points = [[fp] if fp is None else fp for fp in fixed_points] +# for product_point in itertools.product(*fixed_points): +# slice_object = np.array((slice(None), )*len(val.shape), +# dtype=np.object) +# for i, sp in enumerate(spaces): +# point_component = product_point[i] +# if point_component is None: +# point_component = slice(None) +# slice_object[list(domain_axes[sp])] = point_component +# +# slice_object = tuple(slice_object) +# h[slice_object] /= np.sqrt(2) +# a[slice_object] /= np.sqrt(2) return (h, a) @@ -1048,7 +1069,7 @@ class Field(Loggable, Versionable, object): dotted = diagonalOperator(x, spaces=spaces) return dotted.sum(spaces=spaces) - def norm(self, q=2): + def norm(self): """ Computes the Lq-norm of the field values. Parameters @@ -1062,11 +1083,7 @@ class Field(Loggable, Versionable, object): The Lq-norm of the field values. """ - - if q == 2: - return (self.dot(x=self)) ** (1 / 2) - else: - return self.dot(x=self ** (q - 1)) ** (1 / q) + return np.sqrt(np.abs(self.dot(x=self))) def conjugate(self, inplace=False): """ Retruns the complex conjugate of the field. diff --git a/nifty/field_types/__init__.py b/nifty/field_types/__init__.py index cebb34156ff8b529f75d1ba1079ac0a8cc19f337..a9fd176dcd85472a6c5ad37790210a2785624a9b 100644 --- a/nifty/field_types/__init__.py +++ b/nifty/field_types/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from field_type import FieldType from field_array import FieldArray diff --git a/nifty/field_types/field_array.py b/nifty/field_types/field_array.py index bac80ea37fdd739c167058ef2102460d9457c230..48335bb1e9d6fcc43ac664b63942660a7958467a 100644 --- a/nifty/field_types/field_array.py +++ b/nifty/field_types/field_array.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from field_type import FieldType @@ -22,12 +22,14 @@ from field_type import FieldType class FieldArray(FieldType): def __init__(self, shape): + super(FieldArray, self).__init__() try: - new_shape = tuple([int(i) for i in shape]) + self._shape = tuple([int(i) for i in shape]) except TypeError: - new_shape = (int(shape), ) - self._shape = new_shape - super(FieldArray, self).__init__() + self._shape = (int(shape), ) + + def __repr__(self): + return "FieldArray(shape=%r)" % (self.shape, ) @property def shape(self): diff --git a/nifty/field_types/field_type.py b/nifty/field_types/field_type.py index ca3256664058883c2dff91404e12af896697a015..ffb2ff17ecb9894b4da2830bea3e57007a4e8d89 100644 --- a/nifty/field_types/field_type.py +++ b/nifty/field_types/field_type.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from nifty.domain_object import DomainObject diff --git a/nifty/minimization/__init__.py b/nifty/minimization/__init__.py index 83001f4911b1c9564d21cdb8a56860278ca7bc33..ec18339ad552eb727e2eac43c339b769651067d9 100644 --- a/nifty/minimization/__init__.py +++ b/nifty/minimization/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from line_searching import * from conjugate_gradient import ConjugateGradient diff --git a/nifty/minimization/conjugate_gradient.py b/nifty/minimization/conjugate_gradient.py index 181e6d3c133489cc25f1d9291345b8398d0a6c1e..00a12efa9be1f9ce57b899c3c9b37572d0a1ed4e 100644 --- a/nifty/minimization/conjugate_gradient.py +++ b/nifty/minimization/conjugate_gradient.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from __future__ import division import numpy as np diff --git a/nifty/minimization/descent_minimizer.py b/nifty/minimization/descent_minimizer.py index 9e32e524eb0467a1c69b58b3bb1ea1784f4eaef0..46805fa54a9082cc97d24341e104b12004e21e46 100644 --- a/nifty/minimization/descent_minimizer.py +++ b/nifty/minimization/descent_minimizer.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import abc from nifty.nifty_meta import NiftyMeta diff --git a/nifty/minimization/line_searching/__init__.py b/nifty/minimization/line_searching/__init__.py index cfa7d8649cab5ac6845ea66a9bfd0872bc557aa1..1a94b949190ca144303441a8c653af748353db85 100644 --- a/nifty/minimization/line_searching/__init__.py +++ b/nifty/minimization/line_searching/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from line_search import LineSearch from line_search_strong_wolfe import LineSearchStrongWolfe diff --git a/nifty/minimization/line_searching/line_search.py b/nifty/minimization/line_searching/line_search.py index a811bc52d68d770a42fb46221489aa6982fe0c5d..e17f5e787091f47c6fade5068aadbde747fae0db 100644 --- a/nifty/minimization/line_searching/line_search.py +++ b/nifty/minimization/line_searching/line_search.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import abc diff --git a/nifty/minimization/line_searching/line_search_strong_wolfe.py b/nifty/minimization/line_searching/line_search_strong_wolfe.py index 8d97cb2936fa0a923a1a3990d3ca8ead26a500df..c3fcccf2a272ef029845002e380a5f82be8327e1 100644 --- a/nifty/minimization/line_searching/line_search_strong_wolfe.py +++ b/nifty/minimization/line_searching/line_search_strong_wolfe.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np diff --git a/nifty/minimization/relaxed_newton.py b/nifty/minimization/relaxed_newton.py index eeb1650c84830642f8c3cac67ba923d2a2365119..5d7767caecd1f8ef374e7f2468b6f93deda55182 100644 --- a/nifty/minimization/relaxed_newton.py +++ b/nifty/minimization/relaxed_newton.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from .descent_minimizer import DescentMinimizer from .line_searching import LineSearchStrongWolfe diff --git a/nifty/minimization/steepest_descent.py b/nifty/minimization/steepest_descent.py index 8d2311935d8411d20409dffb9d306a081fcadd6d..fae8ab527466048985b7b4c9822823db0ec6faaf 100644 --- a/nifty/minimization/steepest_descent.py +++ b/nifty/minimization/steepest_descent.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from .descent_minimizer import DescentMinimizer diff --git a/nifty/minimization/vl_bfgs.py b/nifty/minimization/vl_bfgs.py index 5eae3af900aea583172edc3c1ab93cb8e449a5d4..d41ae986773052c62164314a5d086ee28756be10 100644 --- a/nifty/minimization/vl_bfgs.py +++ b/nifty/minimization/vl_bfgs.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np diff --git a/nifty/nifty_utilities.py b/nifty/nifty_utilities.py index d4fc9c547e92a2af14f138a6a5fa6e62224f1b19..f565c5667fabfb93950f5c4eef69cdb525099b8e 100644 --- a/nifty/nifty_utilities.py +++ b/nifty/nifty_utilities.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np from itertools import product diff --git a/nifty/operators/__init__.py b/nifty/operators/__init__.py index e0580f19ed7c49b1154a8ef414b5495d2a1bea09..69a02595609812739350528eea8f642b398e2f27 100644 --- a/nifty/operators/__init__.py +++ b/nifty/operators/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from __future__ import division diff --git a/nifty/operators/composed_operator/__init__.py b/nifty/operators/composed_operator/__init__.py index 6890e3f20f5987eb619754f32a386932676dca22..7a7b45ae4074161116e7f9012b9a468346044677 100644 --- a/nifty/operators/composed_operator/__init__.py +++ b/nifty/operators/composed_operator/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,5 +10,10 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from composed_operator import ComposedOperator diff --git a/nifty/operators/composed_operator/composed_operator.py b/nifty/operators/composed_operator/composed_operator.py index d6b833e36c52015448c3c0a676219b279f000c38..66d1a74493541023d274af44c55bb036f4fa6cd8 100644 --- a/nifty/operators/composed_operator/composed_operator.py +++ b/nifty/operators/composed_operator/composed_operator.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from nifty.operators.linear_operator import LinearOperator @@ -131,9 +131,6 @@ class ComposedOperator(LinearOperator): def _adjoint_inverse_times(self, x, spaces): return self._times_helper(x, spaces, func='adjoint_inverse_times') - def _inverse_adjoint_times(self, x, spaces): - return self._times_helper(x, spaces, func='inverse_adjoint_times') - def _times_helper(self, x, spaces, func): space_index = 0 if spaces is None: diff --git a/nifty/operators/diagonal_operator/__init__.py b/nifty/operators/diagonal_operator/__init__.py index a265d0e17149dd22a38bfd695c5e77c1f09f343d..f27fe09a5d9a9effe2e50a27cb8dd1630f418209 100644 --- a/nifty/operators/diagonal_operator/__init__.py +++ b/nifty/operators/diagonal_operator/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,5 +10,10 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from diagonal_operator import DiagonalOperator diff --git a/nifty/operators/diagonal_operator/diagonal_operator.py b/nifty/operators/diagonal_operator/diagonal_operator.py index 467330c7a261182c7c836e30e5f6845112db7701..77f843fc2736aadda966116e66f1608c1cc6fbf2 100644 --- a/nifty/operators/diagonal_operator/diagonal_operator.py +++ b/nifty/operators/diagonal_operator/diagonal_operator.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np diff --git a/nifty/operators/endomorphic_operator/__init__.py b/nifty/operators/endomorphic_operator/__init__.py index 4b1dce953f6b727dfe2f16e93d7aeaccba4592dc..7f2b08f1822418ebdb6cc5fb89c0c78e94e18431 100644 --- a/nifty/operators/endomorphic_operator/__init__.py +++ b/nifty/operators/endomorphic_operator/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,5 +10,10 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from endomorphic_operator import EndomorphicOperator diff --git a/nifty/operators/endomorphic_operator/endomorphic_operator.py b/nifty/operators/endomorphic_operator/endomorphic_operator.py index cde405f480fe4ed649323bfe104c5a21c2bf3fc2..e5ed46862786245629603a577a57e6594a1dd1e0 100644 --- a/nifty/operators/endomorphic_operator/endomorphic_operator.py +++ b/nifty/operators/endomorphic_operator/endomorphic_operator.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import abc diff --git a/nifty/operators/fft_operator/__init__.py b/nifty/operators/fft_operator/__init__.py index ffc3a57347d4cd55ea5203b1c127c300a4cf47a8..c0247fdece024338baf35fc145f7fb27b0944f7a 100644 --- a/nifty/operators/fft_operator/__init__.py +++ b/nifty/operators/fft_operator/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from transformations import * from fft_operator import FFTOperator diff --git a/nifty/operators/fft_operator/fft_operator.py b/nifty/operators/fft_operator/fft_operator.py index b614ef5df6cb196daabb89498377a66ebfed1866..074c963207bfa32040a81cd45a79298088e0de8a 100644 --- a/nifty/operators/fft_operator/fft_operator.py +++ b/nifty/operators/fft_operator/fft_operator.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np diff --git a/nifty/operators/fft_operator/transformations/__init__.py b/nifty/operators/fft_operator/transformations/__init__.py index 0b96384729f40e08eef30cfaef10adc479d7846e..c917fbc7d3664d11f7c91625f8bbbf6229c2a9f0 100644 --- a/nifty/operators/fft_operator/transformations/__init__.py +++ b/nifty/operators/fft_operator/transformations/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from rgrgtransformation import RGRGTransformation from gllmtransformation import GLLMTransformation diff --git a/nifty/operators/fft_operator/transformations/gllmtransformation.py b/nifty/operators/fft_operator/transformations/gllmtransformation.py index a0e47652b85fc8f17adf1c08e1bed23bc4130782..9061ce627a5c972eb74628596c3ae64125d30b92 100644 --- a/nifty/operators/fft_operator/transformations/gllmtransformation.py +++ b/nifty/operators/fft_operator/transformations/gllmtransformation.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np @@ -100,11 +100,6 @@ class GLLMTransformation(SlicingTransformation): super(GLLMTransformation, cls).check_codomain(domain, codomain) def _transformation_of_slice(self, inp, **kwargs): - if inp.dtype not in (np.float, np.complex): - self.logger.warn("The input array has dtype: %s. The FFT will " - "be performed at double precision." % - str(inp.dtype)) - nlat = self.domain.nlat nlon = self.domain.nlon lmax = self.codomain.lmax diff --git a/nifty/operators/fft_operator/transformations/hplmtransformation.py b/nifty/operators/fft_operator/transformations/hplmtransformation.py index 314caa008bc479aa6596ca658410da7fde233585..a416934c8675839833c0490cb5037caa7b682297 100644 --- a/nifty/operators/fft_operator/transformations/hplmtransformation.py +++ b/nifty/operators/fft_operator/transformations/hplmtransformation.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np @@ -92,11 +92,6 @@ class HPLMTransformation(SlicingTransformation): super(HPLMTransformation, cls).check_codomain(domain, codomain) def _transformation_of_slice(self, inp, **kwargs): - if inp.dtype not in (np.float, np.complex): - self.logger.warn("The input array has dtype: %s. The FFT will " - "be performed at double precision." % - str(inp.dtype)) - lmax = self.codomain.lmax mmax = lmax diff --git a/nifty/operators/fft_operator/transformations/lmgltransformation.py b/nifty/operators/fft_operator/transformations/lmgltransformation.py index 5e743c4da5512902dedf85bdcf7c9353748c109d..d153e37f751810b85671aaa55988211614cb4ded 100644 --- a/nifty/operators/fft_operator/transformations/lmgltransformation.py +++ b/nifty/operators/fft_operator/transformations/lmgltransformation.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np from nifty.config import dependency_injector as gdi @@ -106,11 +106,6 @@ class LMGLTransformation(SlicingTransformation): super(LMGLTransformation, cls).check_codomain(domain, codomain) def _transformation_of_slice(self, inp, **kwargs): - if inp.dtype not in (np.float, np.complex): - self.logger.warn("The input array has dtype: %s. The FFT will " - "be performed at double precision." % - str(inp.dtype)) - nlat = self.codomain.nlat nlon = self.codomain.nlon lmax = self.domain.lmax diff --git a/nifty/operators/fft_operator/transformations/lmhptransformation.py b/nifty/operators/fft_operator/transformations/lmhptransformation.py index 6aa87e973ae1429e76d5eb8552d586a69ddea1c3..c4952b113d0d6e7418196b7fc453283c425f7109 100644 --- a/nifty/operators/fft_operator/transformations/lmhptransformation.py +++ b/nifty/operators/fft_operator/transformations/lmhptransformation.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np from nifty.config import dependency_injector as gdi @@ -94,11 +94,6 @@ class LMHPTransformation(SlicingTransformation): super(LMHPTransformation, cls).check_codomain(domain, codomain) def _transformation_of_slice(self, inp, **kwargs): - if inp.dtype not in (np.float, np.complex): - self.logger.warn("The input array has dtype: %s. The FFT will " - "be performed at double precision." % - str(inp.dtype)) - nside = self.codomain.nside lmax = self.domain.lmax mmax = lmax diff --git a/nifty/operators/fft_operator/transformations/rg_transforms.py b/nifty/operators/fft_operator/transformations/rg_transforms.py index 78028f86b6e39aca0a4168119d6ce73f67038071..8a28c9e01664c73ec6b4767af4bd1153e93739e1 100644 --- a/nifty/operators/fft_operator/transformations/rg_transforms.py +++ b/nifty/operators/fft_operator/transformations/rg_transforms.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import warnings @@ -433,11 +433,6 @@ class FFTW(Transform): not all(axis in range(len(val.shape)) for axis in axes): raise ValueError("Provided axes does not match array shape") - if val.dtype not in (np.float, np.complex): - self.logger.warn("The input array has dtype: %s. The FFT will " - "be performed at double precision." % - str(val.dtype)) - # If the input is a numpy array we transform it locally if not isinstance(val, distributed_data_object): # Cast to a np.ndarray @@ -582,11 +577,6 @@ class NUMPYFFT(Transform): not all(axis in range(len(val.shape)) for axis in axes): raise ValueError("Provided axes does not match array shape") - if val.dtype not in (np.float, np.complex): - self.logger.warn("The input array has dtype: %s. The FFT will " - "be performed at double precision." % - str(val.dtype)) - return_val = val.copy_empty(global_shape=val.shape, dtype=np.complex) diff --git a/nifty/operators/fft_operator/transformations/rgrgtransformation.py b/nifty/operators/fft_operator/transformations/rgrgtransformation.py index 62212f351f6e0648d90e80f2d9a61406bd0c7cce..862d78710dc08e87e77a72411c8c3d70cdd06915 100644 --- a/nifty/operators/fft_operator/transformations/rgrgtransformation.py +++ b/nifty/operators/fft_operator/transformations/rgrgtransformation.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np from transformation import Transformation diff --git a/nifty/operators/fft_operator/transformations/slicing_transformation.py b/nifty/operators/fft_operator/transformations/slicing_transformation.py index 6b9f23f8b1f8ba5c906bbf72f5e7c451ff36d65b..8d2b0aa54e482d61914dcfe304c408c1071fd1a9 100644 --- a/nifty/operators/fft_operator/transformations/slicing_transformation.py +++ b/nifty/operators/fft_operator/transformations/slicing_transformation.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import abc import numpy as np diff --git a/nifty/operators/fft_operator/transformations/transformation.py b/nifty/operators/fft_operator/transformations/transformation.py index 3f8c850d27c1e2816bcf029da13ee7dd6bf72da4..a35705d0600d38f24443c4cfd81b0d3f1d286ff6 100644 --- a/nifty/operators/fft_operator/transformations/transformation.py +++ b/nifty/operators/fft_operator/transformations/transformation.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import abc diff --git a/nifty/operators/fft_operator/transformations/transformation_cache.py b/nifty/operators/fft_operator/transformations/transformation_cache.py index ad02de278be019c77704f7b93c59e4c3405ddd2b..26425f7bc79c0d8044899ebde5c89571949ad709 100644 --- a/nifty/operators/fft_operator/transformations/transformation_cache.py +++ b/nifty/operators/fft_operator/transformations/transformation_cache.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. class _TransformationCache(object): diff --git a/nifty/operators/invertible_operator_mixin/__init__.py b/nifty/operators/invertible_operator_mixin/__init__.py index d2013a869a742324d04b0a2b966cdcf540d8e09b..c7a2cb1078604472b26b8e954236c4611fea4869 100644 --- a/nifty/operators/invertible_operator_mixin/__init__.py +++ b/nifty/operators/invertible_operator_mixin/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,5 +10,10 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from invertible_operator_mixin import InvertibleOperatorMixin \ No newline at end of file diff --git a/nifty/operators/invertible_operator_mixin/invertible_operator_mixin.py b/nifty/operators/invertible_operator_mixin/invertible_operator_mixin.py index 4786a4f9375c7e56e6b52d38005263f2b6f69057..e134656b455e290fc5c64605bc3573dae3fadb67 100644 --- a/nifty/operators/invertible_operator_mixin/invertible_operator_mixin.py +++ b/nifty/operators/invertible_operator_mixin/invertible_operator_mixin.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from nifty.minimization import ConjugateGradient @@ -103,7 +103,3 @@ class InvertibleOperatorMixin(object): b=x, x0=x0) return result - - def _inverse_adjoint_times(self, x, spaces): - raise NotImplementedError( - "no generic instance method 'inverse_adjoint_times'.") diff --git a/nifty/operators/linear_operator/__init__.py b/nifty/operators/linear_operator/__init__.py index 1d3303110a360d2dc5ef154deab2b87909f58f77..2b2cb961a042f7386b7d2828f516ac176b79941c 100644 --- a/nifty/operators/linear_operator/__init__.py +++ b/nifty/operators/linear_operator/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,5 +10,10 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from linear_operator import LinearOperator diff --git a/nifty/operators/linear_operator/linear_operator.py b/nifty/operators/linear_operator/linear_operator.py index 64a0d0374cdeb9d4bf6209450134e35304f98da3..c57e03972f33cb6f46ade9abddb704c0a1878727 100644 --- a/nifty/operators/linear_operator/linear_operator.py +++ b/nifty/operators/linear_operator/linear_operator.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import abc from nifty.nifty_meta import NiftyMeta @@ -269,10 +269,6 @@ class LinearOperator(Loggable, object): raise NotImplementedError( "no generic instance method 'adjoint_inverse_times'.") - def _inverse_adjoint_times(self, x, spaces): - raise NotImplementedError( - "no generic instance method 'inverse_adjoint_times'.") - def _check_input_compatibility(self, x, spaces, inverse=False): if not isinstance(x, Field): raise ValueError( diff --git a/nifty/operators/projection_operator/__init__.py b/nifty/operators/projection_operator/__init__.py index 9dc485be102cb873cc025151321288f1c2ed4b2b..9374e34599794a2ed7a9f2d958c7bd8bbd2078b3 100644 --- a/nifty/operators/projection_operator/__init__.py +++ b/nifty/operators/projection_operator/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,5 +10,10 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from projection_operator import ProjectionOperator diff --git a/nifty/operators/projection_operator/projection_operator.py b/nifty/operators/projection_operator/projection_operator.py index 3298b556adee8acb483609a39bf5ff706e4e4c71..998110b06e32293c3e28933ba5184ccd66188439 100644 --- a/nifty/operators/projection_operator/projection_operator.py +++ b/nifty/operators/projection_operator/projection_operator.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np diff --git a/nifty/operators/propagator_operator/__init__.py b/nifty/operators/propagator_operator/__init__.py index 61d962c4299059adbe8f5fab63d8f7dd8a27239b..8214db89ea0d36afb0ecfd75c84d36f22ddd5038 100644 --- a/nifty/operators/propagator_operator/__init__.py +++ b/nifty/operators/propagator_operator/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from propagator_operator import PropagatorOperator from harmonic_propagator_operator import HarmonicPropagatorOperator \ No newline at end of file diff --git a/nifty/operators/propagator_operator/harmonic_propagator_operator.py b/nifty/operators/propagator_operator/harmonic_propagator_operator.py index 908e2e372f992dbd0c7afc7ce8fdbc0c62c94833..221ad2bdecc4a8c097a86fb34b7421f1bde1abc2 100644 --- a/nifty/operators/propagator_operator/harmonic_propagator_operator.py +++ b/nifty/operators/propagator_operator/harmonic_propagator_operator.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from nifty.operators import EndomorphicOperator,\ FFTOperator,\ @@ -83,7 +83,7 @@ class HarmonicPropagatorOperator(InvertibleOperatorMixin, EndomorphicOperator): # ---Overwritten properties and methods--- - def __init__(self, S=None, M=None, R=None, N=None, inverter=None, + def __init__(self, S, M=None, R=None, N=None, inverter=None, preconditioner=None): """ Sets the standard operator properties and `codomain`, `_A1`, `_A2`, @@ -102,7 +102,6 @@ class HarmonicPropagatorOperator(InvertibleOperatorMixin, EndomorphicOperator): """ # infer domain, and target - # infer domain, and target if M is not None: self._codomain = M.domain self._likelihood = M.times diff --git a/nifty/operators/propagator_operator/propagator_operator.py b/nifty/operators/propagator_operator/propagator_operator.py index 6bdf5c163023f994fba9a9e3924d1527ee4b22ea..afb4495c709e09a47708b74de77a2b7b49c2d83f 100644 --- a/nifty/operators/propagator_operator/propagator_operator.py +++ b/nifty/operators/propagator_operator/propagator_operator.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from nifty.operators import EndomorphicOperator,\ FFTOperator,\ diff --git a/nifty/operators/smoothing_operator/__init__.py b/nifty/operators/smoothing_operator/__init__.py index d254e649a9ee6022d12d98fe9acc5851cb50ad8e..c0eb24343de870621853755160542f221837c941 100644 --- a/nifty/operators/smoothing_operator/__init__.py +++ b/nifty/operators/smoothing_operator/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,5 +10,10 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from .smoothing_operator import SmoothingOperator diff --git a/nifty/operators/smoothing_operator/direct_smoothing_operator.py b/nifty/operators/smoothing_operator/direct_smoothing_operator.py index 59ce7406b94bde5c755f6f75e355e3b002f108cf..2e415d62aacb81a4ca97d007912f5650046e9cc8 100644 --- a/nifty/operators/smoothing_operator/direct_smoothing_operator.py +++ b/nifty/operators/smoothing_operator/direct_smoothing_operator.py @@ -144,6 +144,7 @@ class DirectSmoothingOperator(SmoothingOperator): distribution_strategy='not') distance_array = distance_array.get_local_data(copy=False) + #MR FIXME: this causes calls of log(0.) which should probably be avoided if self.log_distances: np.log(distance_array, out=distance_array) diff --git a/nifty/operators/smoothing_operator/fft_smoothing_operator.py b/nifty/operators/smoothing_operator/fft_smoothing_operator.py index 2e764bee29aef937920862bdce9ed318eb32998e..f4f3de8f194f7a8537ed1cacd3e33e0dda216e2f 100644 --- a/nifty/operators/smoothing_operator/fft_smoothing_operator.py +++ b/nifty/operators/smoothing_operator/fft_smoothing_operator.py @@ -24,6 +24,7 @@ class FFTSmoothingOperator(SmoothingOperator): kernel = codomain.get_distance_array( distribution_strategy=axes_local_distribution_strategy) + #MR FIXME: this causes calls of log(0.) which should probably be avoided if self.log_distances: kernel.apply_scalar_function(np.log, inplace=True) @@ -43,6 +44,7 @@ class FFTSmoothingOperator(SmoothingOperator): # apply the kernel if inverse: + #MR FIXME: danger of having division by zero or overflows local_transformed_x /= local_kernel else: local_transformed_x *= local_kernel diff --git a/nifty/operators/smoothing_operator/smoothing_operator.py b/nifty/operators/smoothing_operator/smoothing_operator.py index cdc34cfff71f2f811045275c9685d05387decd0e..b306b8c2d3b1f1274d0a35c42406614694335e36 100644 --- a/nifty/operators/smoothing_operator/smoothing_operator.py +++ b/nifty/operators/smoothing_operator/smoothing_operator.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import abc @@ -39,11 +39,12 @@ class SmoothingOperator(EndomorphicOperator): can only live on one space or FieldType sigma : float Sets the length of the Gaussian convolution kernel - log_distances : boolean - States whether the convolution happens on the logarithmic grid or not. + log_distances : boolean *optional* + States whether the convolution happens on the logarithmic grid or not + (default: False). default_spaces : tuple of ints *optional* Defines on which space(s) of a given field the Operator acts by - default (default: None) + default (default: None). Attributes ---------- @@ -117,7 +118,6 @@ class SmoothingOperator(EndomorphicOperator): raise NotImplementedError("For the given Space smoothing " " is not available.") else: - print 'new 4' return super(SmoothingOperator, cls).__new__(cls, domain, *args, diff --git a/nifty/plotting/figures/figure_2D.py b/nifty/plotting/figures/figure_2D.py index 8464644ae855729b8e379a1f1a018a75d9d18363..16c41960dbe9948e55e2c61afd3361814edecae0 100644 --- a/nifty/plotting/figures/figure_2D.py +++ b/nifty/plotting/figures/figure_2D.py @@ -1,36 +1,50 @@ # -*- coding: utf-8 -*- from figure_from_plot import FigureFromPlot -from nifty.plotting.plots import Heatmap, Mollweide +from nifty.plotting.plots import Heatmap, HPMollweide, GLMollweide class Figure2D(FigureFromPlot): def __init__(self, plots, title=None, width=None, height=None, xaxis=None, yaxis=None): - super(Figure2D, self).__init__(plots, title, width, height) - # TODO: add sanitization of plots input - if isinstance(plots[0], Heatmap) and not width and not height: - (x, y) = plots[0].data.shape + if plots is not None: + if isinstance(plots[0], Heatmap) and width is None and \ + height is None: + (x, y) = plots[0].data.shape + + if x > y: + width = 500 + height = int(500*y/x) + else: + height = 500 + width = int(500 * y / x) + + if isinstance(plots[0], GLMollweide) or \ + isinstance(plots[0], HPMollweide): + xaxis = False if (xaxis is None) else xaxis + yaxis = False if (yaxis is None) else yaxis - if x > y: - width = 500 - height = int(500*y/x) else: - height = 500 - width = int(500 * y / x) - if isinstance(plots[0], Mollweide): - if not xaxis: - xaxis = False - if not yaxis: - yaxis = False + width = None + height = None super(Figure2D, self).__init__(plots, title, width, height) self.xaxis = xaxis self.yaxis = yaxis + def at(self, plots): + return Figure2D(plots=plots, + title=self.title, + width=self.width, + height=self.height, + xaxis=self.xaxis, + yaxis=self.yaxis) + def to_plotly(self): + plotly_object = super(Figure2D, self).to_plotly() + if self.xaxis or self.yaxis: plotly_object['layout']['scene']['aspectratio'] = {} if self.xaxis: diff --git a/nifty/plotting/figures/figure_3D.py b/nifty/plotting/figures/figure_3D.py index 0fad09a7c311833d4646d0eecdcf11b1e7aecc52..f26566c798916c8ce8917a5e369a931366908947 100644 --- a/nifty/plotting/figures/figure_3D.py +++ b/nifty/plotting/figures/figure_3D.py @@ -10,6 +10,15 @@ class Figure3D(FigureFromPlot): self.yaxis = yaxis self.zaxis = zaxis + def at(self, plots): + return Figure3D(plots=plots, + title=self.title, + width=self.width, + height=self.height, + xaxis=self.xaxis, + yaxis=self.yaxis, + zaxis=self.zaxis) + def to_plotly(self): plotly_object = super(Figure3D, self).to_plotly() if self.xaxis or self.yaxis or self.zaxis: diff --git a/nifty/plotting/figures/figure_base.py b/nifty/plotting/figures/figure_base.py index 19221399d378820b84ae0b68d280ea18b2c21791..ee7d2cbaf6ab9fd3221c8a0e43e7b18852c36f6c 100644 --- a/nifty/plotting/figures/figure_base.py +++ b/nifty/plotting/figures/figure_base.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from abc import abstractmethod +import abc from nifty.plotting.plotly_wrapper import PlotlyWrapper @@ -11,6 +11,10 @@ class FigureBase(PlotlyWrapper): self.width = width self.height = height - @abstractmethod + @abc.abstractmethod + def at(self): + raise NotImplementedError + + @abc.abstractmethod def to_plotly(self): raise NotImplementedError diff --git a/nifty/plotting/figures/multi_figure.py b/nifty/plotting/figures/multi_figure.py index fc9ef467a3ca45691094be5ff1bb3c44b9f514b0..1eab5824870fa872490c669ac01e746324523964 100644 --- a/nifty/plotting/figures/multi_figure.py +++ b/nifty/plotting/figures/multi_figure.py @@ -10,13 +10,21 @@ plotly = gdi.get('plotly') # TODO: add nice height and width defaults for multifigure class MultiFigure(FigureBase): - def __init__(self, rows, columns, title=None, width=None, height=None, - subfigures=None): + def __init__(self, subfigures, title=None, width=None, height=None): if 'plotly' not in gdi: raise ImportError("The module plotly is needed but not available.") super(MultiFigure, self).__init__(title, width, height) - self.subfigures = np.empty((rows, columns), dtype=np.object) - self.subfigures[:] = subfigures + if subfigures is not None: + self.subfigures = np.asarray(subfigures, dtype=np.object) + if len(self.subfigures.shape) != 2: + raise ValueError("Subfigures must be a two-dimensional array.") + + + def at(self, subfigures): + return MultiFigure(subfigures=subfigures, + title=self.title, + width=self.width, + height=self.height) @property def rows(self): @@ -26,15 +34,15 @@ class MultiFigure(FigureBase): def columns(self): return self.subfigures.shape[1] - def add_subfigure(self, figure, row, column): - self.subfigures[row, column] = figure - def to_plotly(self): title_extractor = lambda z: z.title if z else "" - sub_titles = tuple(np.vectorize(title_extractor)(self.subfigures.flatten())) + sub_titles = tuple(np.vectorize(title_extractor)( + self.subfigures.flatten())) - specs_setter = lambda z: {'is_3d': True} if isinstance(z, Figure3D) else {} - sub_specs = list(map(list, np.vectorize(specs_setter)(self.subfigures))) + specs_setter = lambda z: ({'is_3d': True} + if isinstance(z, Figure3D) else {}) + sub_specs = list(map(list, np.vectorize(specs_setter)( + self.subfigures))) multi_figure_plotly_object = plotly.tools.make_subplots( self.rows, @@ -46,7 +54,7 @@ class MultiFigure(FigureBase): width=self.width, title=self.title) - #TODO resolve bug with titles and 3D subplots + # TODO resolve bug with titles and 3D subplots i = 1 for index, fig in np.ndenumerate(self.subfigures): diff --git a/nifty/plotting/plots/heatmaps/__init__.py b/nifty/plotting/plots/heatmaps/__init__.py index 72d97c0e1bb2c4d9f67d1359972c7965784641d0..64fda3783d6a87df18bd316b174f39c5099925d2 100644 --- a/nifty/plotting/plots/heatmaps/__init__.py +++ b/nifty/plotting/plots/heatmaps/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- -from mollweide import Mollweide +from hpmollweide import HPMollweide +from glmollweide import GLMollweide from heatmap import Heatmap diff --git a/nifty/plotting/plots/heatmaps/glmollweide.py b/nifty/plotting/plots/heatmaps/glmollweide.py new file mode 100644 index 0000000000000000000000000000000000000000..7f4d69d82f780074e85a518ba48fe93d2e3d0de6 --- /dev/null +++ b/nifty/plotting/plots/heatmaps/glmollweide.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- + +from nifty import dependency_injector as gdi +from heatmap import Heatmap +import numpy as np + +from .mollweide_helper import mollweide_helper + +pyHealpix = gdi.get('pyHealpix') + + +class GLMollweide(Heatmap): + def __init__(self, data, xsize=800, color_map=None, + webgl=False, smoothing=False): + # smoothing 'best', 'fast', False + if 'pyHealpix' not in gdi: + raise ImportError( + "The module pyHealpix is needed but not available.") + self.xsize = xsize + + super(GLMollweide, self).__init__(data, color_map, webgl, smoothing) + + def at(self, data): + if isinstance(data, list): + data = [self._mollview(d) for d in data] + else: + data = self._mollview(data) + return GLMollweide(data=data, + xsize=self.xsize, + color_map=self.color_map, + webgl=self.webgl, + smoothing=self.smoothing) + + @staticmethod + def _find_closest(A, target): + # A must be sorted + idx = A.searchsorted(target) + idx = np.clip(idx, 1, len(A)-1) + left = A[idx-1] + right = A[idx] + idx -= target - left < right - target + return idx + + def _mollview(self, x): + xsize = self.xsize + nlat = x.shape[0] + nlon = x.shape[1] + + res, mask, theta, phi = mollweide_helper(xsize) + + ra = np.linspace(0, 2*np.pi, nlon+1) + dec = pyHealpix.GL_thetas(nlat) + ilat = self._find_closest(dec, theta) + ilon = self._find_closest(ra, phi) + ilon = np.where(ilon == nlon, 0, ilon) + res[mask] = x[ilat, ilon] + return res diff --git a/nifty/plotting/plots/heatmaps/heatmap.py b/nifty/plotting/plots/heatmaps/heatmap.py index 853e95c973aae28feb22932463f9a152039b055d..9ab0ce6c9a1e0274c2753b9af698578be1ca726c 100644 --- a/nifty/plotting/plots/heatmaps/heatmap.py +++ b/nifty/plotting/plots/heatmaps/heatmap.py @@ -6,14 +6,8 @@ from nifty.plotting.plotly_wrapper import PlotlyWrapper class Heatmap(PlotlyWrapper): - def __init__(self, data, color_map=None, webgl=False, - smoothing=False): # smoothing 'best', 'fast', False - if isinstance(data, list): - self.data = np.zeros((data[0].shape)) - for arr in data: - self.data = np.add(self.data, arr) - else: - self.data = data + def __init__(self, data, color_map=None, webgl=False, smoothing=False): + # smoothing 'best', 'fast', False if color_map is not None: if not isinstance(color_map, Colormap): @@ -22,6 +16,19 @@ class Heatmap(PlotlyWrapper): self.color_map = color_map self.webgl = webgl self.smoothing = smoothing + self.data = data + + def at(self, data): + if isinstance(data, list): + temp_data = np.zeros((data[0].shape)) + for arr in data: + temp_data = np.add(temp_data, arr) + else: + temp_data = data + return Heatmap(data=temp_data, + color_map=self.color_map, + webgl=self.webgl, + smoothing=self.smoothing) @property def figure_dimension(self): @@ -29,7 +36,9 @@ class Heatmap(PlotlyWrapper): def to_plotly(self): plotly_object = dict() + plotly_object['z'] = self.data + plotly_object['showscale'] = False if self.color_map: plotly_object['colorscale'] = self.color_map.to_plotly() diff --git a/nifty/plotting/plots/heatmaps/hpmollweide.py b/nifty/plotting/plots/heatmaps/hpmollweide.py new file mode 100644 index 0000000000000000000000000000000000000000..71cefbcda7eeb2651ed0c430bf7e8b79832db036 --- /dev/null +++ b/nifty/plotting/plots/heatmaps/hpmollweide.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +from nifty import dependency_injector as gdi +from heatmap import Heatmap +import numpy as np + +from .mollweide_helper import mollweide_helper + +pyHealpix = gdi.get('pyHealpix') + + +class HPMollweide(Heatmap): + def __init__(self, data, xsize=800, color_map=None, webgl=False, + smoothing=False): # smoothing 'best', 'fast', False + if 'pyHealpix' not in gdi: + raise ImportError( + "The module pyHealpix is needed but not available.") + self.xsize = xsize + super(HPMollweide, self).__init__(data, color_map, webgl, smoothing) + + def at(self, data): + if isinstance(data, list): + data = [self._mollview(d) for d in data] + else: + data = self._mollview(data) + return HPMollweide(data=data, + xsize=self.xsize, + color_map=self.color_map, + webgl=self.webgl, + smoothing=self.smoothing) + + def _mollview(self, x): + xsize = self.xsize + res, mask, theta, phi = mollweide_helper(xsize) + + ptg = np.empty((phi.size, 2), dtype=np.float64) + ptg[:, 0] = theta + ptg[:, 1] = phi + base = pyHealpix.Healpix_Base(int(np.sqrt(x.size/12)), "RING") + res[mask] = x[base.ang2pix(ptg)] + return res diff --git a/nifty/plotting/plots/heatmaps/mollweide.py b/nifty/plotting/plots/heatmaps/mollweide.py deleted file mode 100644 index 8b5b079bbc2066a5bd1a35eb2e4aa9ab36245ed7..0000000000000000000000000000000000000000 --- a/nifty/plotting/plots/heatmaps/mollweide.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- - -from nifty import dependency_injector as gdi -from heatmap import Heatmap - -pylab = gdi.get('pylab') -healpy = gdi.get('healpy') - - -class Mollweide(Heatmap): - def __init__(self, data, color_map=None, webgl=False, - smoothing=False): # smoothing 'best', 'fast', False - if 'pylab' not in gdi: - raise ImportError("The module pylab is needed but not available.") - if 'healpy' not in gdi: - raise ImportError("The module healpy is needed but not available.") - if isinstance(data, list): - data = [self._mollview(d) for d in data] - else: - data = self._mollview(data) - super(Mollweide, self).__init__(data, color_map, webgl, smoothing) - - def _mollview(self, x, xsize=800): - x = healpy.pixelfunc.ma_to_array(x) - f = pylab.figure(None, figsize=(8.5, 5.4)) - extent = (0.02, 0.05, 0.96, 0.9) - ax = healpy.projaxes.HpxMollweideAxes(f, extent) - img = ax.projmap(x, nest=False, xsize=xsize) - return img diff --git a/nifty/plotting/plots/heatmaps/mollweide_helper.py b/nifty/plotting/plots/heatmaps/mollweide_helper.py new file mode 100644 index 0000000000000000000000000000000000000000..baa0bbfdcf270c6b35446b620de15cabfd4a76a7 --- /dev/null +++ b/nifty/plotting/plots/heatmaps/mollweide_helper.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +import numpy as np + + +def mollweide_helper(xsize): + xsize = int(xsize) + ysize = int(xsize/2) + res = np.full(shape=(ysize, xsize), fill_value=np.nan, + dtype=np.float64) + xc = (xsize-1)*0.5 + yc = (ysize-1)*0.5 + u, v = np.meshgrid(np.arange(xsize), np.arange(ysize)) + u = 2*(u-xc)/(xc/1.02) + v = (v-yc)/(yc/1.02) + + mask = np.where((u*u*0.25 + v*v) <= 1.) + t1 = v[mask] + theta = 0.5*np.pi-( + np.arcsin(2/np.pi*(np.arcsin(t1) + t1*np.sqrt((1.-t1)*(1+t1))))) + phi = -0.5*np.pi*u[mask]/np.maximum(np.sqrt((1-t1)*(1+t1)), 1e-6) + phi = np.where(phi < 0, phi+2*np.pi, phi) + return res, mask, theta, phi diff --git a/nifty/plotting/plots/scatter_plots/cartesian.py b/nifty/plotting/plots/scatter_plots/cartesian.py index bd635625a18a11a6f8faf6909ff31c07e431a786..2df5f1412a09d77339e6418c0a6a313caafb3165 100644 --- a/nifty/plotting/plots/scatter_plots/cartesian.py +++ b/nifty/plotting/plots/scatter_plots/cartesian.py @@ -4,16 +4,14 @@ from scatter_plot import ScatterPlot class Cartesian(ScatterPlot): - def __init__(self, x, y, label, line, marker, showlegend=True): - super(Cartesian, self).__init__(label, line, marker) - self.x = x - self.y = y + def __init__(self, data, label, line, marker, showlegend=True): + super(Cartesian, self).__init__(data, label, line, marker) self.showlegend = showlegend @abstractmethod def to_plotly(self): plotly_object = super(Cartesian, self).to_plotly() - plotly_object['x'] = self.x - plotly_object['y'] = self.y + plotly_object['x'] = self.data[0] + plotly_object['y'] = self.data[1] plotly_object['showlegend'] = self.showlegend return plotly_object diff --git a/nifty/plotting/plots/scatter_plots/cartesian_2D.py b/nifty/plotting/plots/scatter_plots/cartesian_2D.py index d65d86565758865888bb35c9ad7b225381cc4444..579193922cb2e17ec1c0166edbe0afc70a5994d8 100644 --- a/nifty/plotting/plots/scatter_plots/cartesian_2D.py +++ b/nifty/plotting/plots/scatter_plots/cartesian_2D.py @@ -4,17 +4,20 @@ from cartesian import Cartesian class Cartesian2D(Cartesian): - def __init__(self, x=None, y=None, x_start=0, x_step=1, - label='', line=None, marker=None, showlegend=True, + def __init__(self, data, label='', line=None, marker=None, showlegend=True, webgl=True): - if y is None: - raise Exception('Error: no y data to plot') - if x is None: - x = range(x_start, len(y) * x_step, x_step) - super(Cartesian2D, self).__init__(x, y, label, line, marker, + super(Cartesian2D, self).__init__(data, label, line, marker, showlegend) self.webgl = webgl + def at(self, data): + return Cartesian2D(data=data, + label=self.label, + line=self.line, + marker=self.marker, + showlegend=self.showlegend, + webgl=self.webgl) + @property def figure_dimension(self): return 2 diff --git a/nifty/plotting/plots/scatter_plots/cartesian_3D.py b/nifty/plotting/plots/scatter_plots/cartesian_3D.py index 26fc3927ef50a764f17657d67e15a29ad85d251c..5355403f340889d1cebccf5d8eaba4936de37e8d 100644 --- a/nifty/plotting/plots/scatter_plots/cartesian_3D.py +++ b/nifty/plotting/plots/scatter_plots/cartesian_3D.py @@ -4,11 +4,17 @@ from cartesian import Cartesian class Cartesian3D(Cartesian): - def __init__(self, x, y, z, label='', line=None, marker=None, + def __init__(self, data, label='', line=None, marker=None, showlegend=True): - super(Cartesian3D, self).__init__(x, y, label, line, marker, + super(Cartesian3D, self).__init__(data, label, line, marker, showlegend) - self.z = z + + def at(self, data): + return Cartesian3D(data=data, + label=self.label, + line=self.line, + marker=self.marker, + showlegend=self.showlegend) @property def figure_dimension(self): @@ -16,6 +22,6 @@ class Cartesian3D(Cartesian): def to_plotly(self): plotly_object = super(Cartesian3D, self).to_plotly() - plotly_object['z'] = self.z + plotly_object['z'] = self.data[2] plotly_object['type'] = 'scatter3d' return plotly_object diff --git a/nifty/plotting/plots/scatter_plots/geo.py b/nifty/plotting/plots/scatter_plots/geo.py index 9ba4f9986968f1c13c38667d967468699184fedd..8373ead0350c04b5d5ddb05aaa87580491515358 100644 --- a/nifty/plotting/plots/scatter_plots/geo.py +++ b/nifty/plotting/plots/scatter_plots/geo.py @@ -3,26 +3,31 @@ from scatter_plot import ScatterPlot class Geo(ScatterPlot): - def __init__(self, lon, lat, label='', line=None, marker=None, - proj='mollweide'): + def __init__(self, data, label='', line=None, marker=None, + projection='mollweide'): """ proj: mollweide or mercator """ - super.__init__(label, line, marker) - self.lon = lon - self.lat = lat - self.projection = proj + super(Geo, self).__init__(label, line, marker) + self.projection = projection + + def at(self, data): + return Geo(data=data, + label=self.label, + line=self.line, + marker=self.marker, + projection=self.projection) @property def figure_dimension(self): return 2 - def _to_plotly(self): + def _to_plotly(self, data): plotly_object = super(Geo, self).to_plotly() - plotly_object['type'] = 'scattergeo' - plotly_object['lon'] = self.lon - plotly_object['lat'] = self.lat + plotly_object['type'] = self.projection + plotly_object['lon'] = data[0] + plotly_object['lat'] = data[1] if self.line: plotly_object['mode'] = 'lines' return plotly_object diff --git a/nifty/plotting/plots/scatter_plots/scatter_plot.py b/nifty/plotting/plots/scatter_plots/scatter_plot.py index 563c4d01881234a5862a5bbc83d37f4460713386..c5603ff00f81e1ae82e8c2501753b4b32fe79fa1 100644 --- a/nifty/plotting/plots/scatter_plots/scatter_plot.py +++ b/nifty/plotting/plots/scatter_plots/scatter_plot.py @@ -7,7 +7,8 @@ from nifty.plotting.descriptors import Marker,\ class ScatterPlot(PlotlyWrapper): - def __init__(self, label, line, marker): + def __init__(self, data, label, line, marker): + self.data = data self.label = label self.line = line self.marker = marker @@ -15,6 +16,10 @@ class ScatterPlot(PlotlyWrapper): self.marker = Marker() self.line = Line() + @abc.abstractmethod + def at(self, data): + raise NotImplementedError + @abc.abstractproperty def figure_dimension(self): raise NotImplementedError diff --git a/nifty/plotting/plotter/__init__.py b/nifty/plotting/plotter/__init__.py index d7f8d96619247c733c68eda99c1b5200167b141f..f7b0965fded70ae5dae7d8f15829b529a0556745 100644 --- a/nifty/plotting/plotter/__init__.py +++ b/nifty/plotting/plotter/__init__.py @@ -1,3 +1,5 @@ from healpix_plotter import HealpixPlotter +from gl_plotter import GLPlotter from power_plotter import PowerPlotter +from rg2d_plotter import RG2DPlotter diff --git a/nifty/plotting/plotter/gl_plotter.py b/nifty/plotting/plotter/gl_plotter.py new file mode 100644 index 0000000000000000000000000000000000000000..0031738e61a462c29e42c77fc96fcec542d2285f --- /dev/null +++ b/nifty/plotting/plotter/gl_plotter.py @@ -0,0 +1,31 @@ + +import numpy as np + +from nifty.spaces import GLSpace + +from nifty.plotting.figures import Figure2D +from nifty.plotting.plots import GLMollweide +from .plotter_base import PlotterBase + + +class GLPlotter(PlotterBase): + def __init__(self, interactive=False, path='.', title="", color_map=None): + self.color_map = color_map + super(GLPlotter, self).__init__(interactive, path, title) + + @property + def domain_classes(self): + return (GLSpace, ) + + def _initialize_plot(self): + result_plot = GLMollweide(data=None, + color_map=self.color_map) + return result_plot + + def _initialize_figure(self): + return Figure2D(plots=None) + + def _parse_data(self, data, field, spaces): + gl_space = field.domain[spaces[0]] + data = np.reshape(data, (gl_space.nlat, gl_space.nlon)) + return data diff --git a/nifty/plotting/plotter/healpix_plotter.py b/nifty/plotting/plotter/healpix_plotter.py index 72e953a3caa3e0a77e241e769fb22afb600456b7..33eb6863971ab9afcefe08781ee7c282186a8c31 100644 --- a/nifty/plotting/plotter/healpix_plotter.py +++ b/nifty/plotting/plotter/healpix_plotter.py @@ -1,23 +1,23 @@ from nifty.spaces import HPSpace from nifty.plotting.figures import Figure2D -from nifty.plotting.plots import Mollweide -from .plotter import Plotter +from nifty.plotting.plots import HPMollweide +from .plotter_base import PlotterBase -class HealpixPlotter(Plotter): +class HealpixPlotter(PlotterBase): def __init__(self, interactive=False, path='.', title="", color_map=None): - super(HealpixPlotter, self).__init__(interactive, path, title) self.color_map = color_map + super(HealpixPlotter, self).__init__(interactive, path, title) @property def domain_classes(self): return (HPSpace, ) - def _create_individual_figure(self, plots): - return Figure2D(plots) - - def _create_individual_plot(self, data, plot_domain): - result_plot = Mollweide(data=data, - color_map=self.color_map) + def _initialize_plot(self): + result_plot = HPMollweide(data=None, + color_map=self.color_map) return result_plot + + def _initialize_figure(self): + return Figure2D(plots=None) diff --git a/nifty/plotting/plotter/plotter.py b/nifty/plotting/plotter/plotter_base.py similarity index 79% rename from nifty/plotting/plotter/plotter.py rename to nifty/plotting/plotter/plotter_base.py index 487ed4c1ad3d74ca6595a43c8d0e1e7c589a2495..18b545cee0b7d1fcf3c81212df524c48a8d41dbe 100644 --- a/nifty/plotting/plotter/plotter.py +++ b/nifty/plotting/plotter/plotter_base.py @@ -27,7 +27,7 @@ rank = d2o.config.dependency_injector[ d2o.configuration['mpi_module']].COMM_WORLD.rank -class Plotter(Loggable, object): +class PlotterBase(Loggable, object): __metaclass__ = abc.ABCMeta def __init__(self, interactive=False, path='.', title=""): @@ -37,6 +37,10 @@ class Plotter(Loggable, object): self.path = path self.title = str(title) + self.plot = self._initialize_plot() + self.figure = self._initialize_figure() + self.multi_figure = self._initialize_multifigure() + @abc.abstractproperty def domain_classes(self): return (Space,) @@ -57,7 +61,7 @@ class Plotter(Loggable, object): def path(self, new_path): self._path = os.path.normpath(new_path) - def plot(self, fields, spaces=None, data_extractor=None, labels=None): + def __call__(self, fields, spaces=None, data_extractor=None, labels=None): if isinstance(fields, Field): fields = [fields] elif not isinstance(fields, list): @@ -82,12 +86,12 @@ class Plotter(Loggable, object): plots_list = [] for slice_list in utilities.get_slice_list(data_list[0].shape, axes): plots_list += \ - [[self._create_individual_plot(current_data[slice_list], - plot_domain) - for current_data in data_list]] + [[self.plot.at(self._parse_data(current_data, + field, + spaces)) + for (current_data, field) in zip(data_list, fields)]] - figures = [self._create_individual_figure(plots) - for plots in plots_list] + figures = [self.figure.at(plots) for plots in plots_list] self._finalize_figure(figures) @@ -103,13 +107,16 @@ class Plotter(Loggable, object): return data @abc.abstractmethod - def _create_individual_figure(self, plots): + def _initialize_plot(self): raise NotImplementedError @abc.abstractmethod - def _create_individual_plot(self, data, fields): + def _initialize_figure(self): raise NotImplementedError + def _initialize_multifigure(self): + return MultiFigure(subfigures=None) + def _finalize_figure(self, figures): if len(figures) > 1: rows = (len(figures) + 1)//2 @@ -117,9 +124,7 @@ class Plotter(Loggable, object): figure_array[:len(figures)] = figures figure_array = figure_array.reshape((2, rows)) - final_figure = MultiFigure(rows, 2, - title='Test', - subfigures=figure_array) + final_figure = self.multi_figure(subfigures=figure_array) else: final_figure = figures[0] diff --git a/nifty/plotting/plotter/power_plotter.py b/nifty/plotting/plotter/power_plotter.py index 608d5f9818c3b942f771c34d10634fcdae6c9594..12654a7b7ee2785fe024d01ba0d13abeeb570015 100644 --- a/nifty/plotting/plotter/power_plotter.py +++ b/nifty/plotting/plotter/power_plotter.py @@ -1,14 +1,16 @@ # -*- coding: utf-8 -*- +import numpy as np + from nifty.spaces import PowerSpace from nifty.plotting.descriptors import Axis from nifty.plotting.figures import Figure2D from nifty.plotting.plots import Cartesian2D -from .plotter import Plotter +from .plotter_base import PlotterBase -class PowerPlotter(Plotter): +class PowerPlotter(PlotterBase): def __init__(self, interactive=False, path='.', title="", line=None, marker=None): super(PowerPlotter, self).__init__(interactive, path, title) @@ -19,13 +21,18 @@ class PowerPlotter(Plotter): def domain_classes(self): return (PowerSpace, ) - def _create_individual_figure(self, plots): + def _initialize_plot(self): + return Cartesian2D(data=None) + + def _initialize_figure(self): xaxis = Axis(log=True) yaxis = Axis(log=True) - return Figure2D(plots, xaxis=xaxis, yaxis=yaxis) + return Figure2D(plots=None, xaxis=xaxis, yaxis=yaxis) - def _create_individual_plot(self, data, plot_domain): - x = plot_domain[0].kindex - result_plot = Cartesian2D(x=x, - y=data) - return result_plot + def _parse_data(self, data, field, spaces): + y_data = data + power_space = field.domain[spaces[0]] + xy_data = np.empty((2, y_data.shape[0])) + xy_data[1] = y_data + xy_data[0] = power_space.kindex + return xy_data diff --git a/nifty/plotting/plotter/rg2d_plotter.py b/nifty/plotting/plotter/rg2d_plotter.py new file mode 100644 index 0000000000000000000000000000000000000000..b345ecbb8a1cb5a0d1d6571c28c5cca0b6b30f01 --- /dev/null +++ b/nifty/plotting/plotter/rg2d_plotter.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + + +from nifty.spaces import RGSpace +from nifty.plotting.figures import Figure2D +from nifty.plotting.plots import Heatmap +from .plotter_base import PlotterBase + + +class RG2DPlotter(PlotterBase): + def __init__(self, interactive=False, path='.', title="", color_map=None): + self.color_map = color_map + super(RG2DPlotter, self).__init__(interactive, path, title) + + @property + def domain_classes(self): + return (RGSpace, ) + + def _initialize_plot(self): + return Heatmap(data=None, + color_map=self.color_map) + + def _initialize_figure(self): + return Figure2D(plots=None) + + def _parse_data(self, data, field, spaces): + if len(data.shape) != 2: + AttributeError("Only 2-dimensional RGSpaces are supported") + return data diff --git a/nifty/probing/__init__.py b/nifty/probing/__init__.py index a33cbb981d4d044a57a6f41d70ab7c7ce210e371..dc798b264864ded720c748036c79eb2adbab327f 100644 --- a/nifty/probing/__init__.py +++ b/nifty/probing/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from prober import Prober from mixin_classes import * diff --git a/nifty/probing/mixin_classes/__init__.py b/nifty/probing/mixin_classes/__init__.py index 75a3db6ff5742d4585d57d2c4a09a9ed247a34e7..00863b525b2b282f2d6b3f81e4d42f0a1292f23c 100644 --- a/nifty/probing/mixin_classes/__init__.py +++ b/nifty/probing/mixin_classes/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from diagonal_prober_mixin import DiagonalProberMixin from trace_prober_mixin import TraceProberMixin diff --git a/nifty/probing/mixin_classes/diagonal_prober_mixin.py b/nifty/probing/mixin_classes/diagonal_prober_mixin.py index 7c64b84ef69f3a25b056b7676f8a0c8b30831169..0432050dbe815e3b7b68b9fab15b96083081ab81 100644 --- a/nifty/probing/mixin_classes/diagonal_prober_mixin.py +++ b/nifty/probing/mixin_classes/diagonal_prober_mixin.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. class DiagonalProberMixin(object): diff --git a/nifty/probing/mixin_classes/trace_prober_mixin.py b/nifty/probing/mixin_classes/trace_prober_mixin.py index f77d22b390392a3acf49d8d04e90273f45fd7efc..713e3b547d9af8414f9eda9baa6e5de6d062fde9 100644 --- a/nifty/probing/mixin_classes/trace_prober_mixin.py +++ b/nifty/probing/mixin_classes/trace_prober_mixin.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. class TraceProberMixin(object): diff --git a/nifty/probing/prober/__init__.py b/nifty/probing/prober/__init__.py index db2ef5450c7c4ce3e17c3e097a3471814fec6003..5ccbcce873632622797aaa9deff2777434bb86d5 100644 --- a/nifty/probing/prober/__init__.py +++ b/nifty/probing/prober/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,5 +10,10 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from prober import Prober diff --git a/nifty/probing/prober/prober.py b/nifty/probing/prober/prober.py index fcad98a4d70177f5d89ba373aa04ab39a586cdf0..b2f85f54335f2027bd50ab996c69d0979ae2a9e9 100644 --- a/nifty/probing/prober/prober.py +++ b/nifty/probing/prober/prober.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np diff --git a/nifty/random.py b/nifty/random.py index f5642564b3026bd7fd17aa5d16fbd439528130bb..1246517f9c4adfb08b0927b50621427140ab06f0 100644 --- a/nifty/random.py +++ b/nifty/random.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np diff --git a/nifty/spaces/__init__.py b/nifty/spaces/__init__.py index cccb26749f1d199d3eb316073a8355c917ba08c7..81c572d443955a40f19680e6bb8d14d94d6ec851 100644 --- a/nifty/spaces/__init__.py +++ b/nifty/spaces/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from gl_space import GLSpace from hp_space import HPSpace diff --git a/nifty/spaces/gl_space/__init__.py b/nifty/spaces/gl_space/__init__.py index da13b8aea819b298138a4f0bc2483d95ec605391..1856f20a02ec3f84e705a2de36832baf3bb0403f 100644 --- a/nifty/spaces/gl_space/__init__.py +++ b/nifty/spaces/gl_space/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,5 +10,10 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from gl_space import GLSpace diff --git a/nifty/spaces/gl_space/gl_space.py b/nifty/spaces/gl_space/gl_space.py index 8f79829e4bb858beebd563867d34cb3236f9a4ba..0f1168f90af5f8435fce50c06a93f8f4f0324685 100644 --- a/nifty/spaces/gl_space/gl_space.py +++ b/nifty/spaces/gl_space/gl_space.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from __future__ import division @@ -100,6 +100,9 @@ class GLSpace(Space): # ---Mandatory properties and methods--- + def __repr__(self): + return ("GLSpace(nlat=%r, nlon=%r)" % (self.nlat, self.nlon)) + @property def harmonic(self): return False diff --git a/nifty/spaces/hp_space/__init__.py b/nifty/spaces/hp_space/__init__.py index 9ed3c8abf82cb6486528b23129d2e1658f6e6edb..9f6bf29c14fffb021a433802bdfb3b0509f93244 100644 --- a/nifty/spaces/hp_space/__init__.py +++ b/nifty/spaces/hp_space/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,5 +10,10 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from hp_space import HPSpace diff --git a/nifty/spaces/hp_space/hp_space.py b/nifty/spaces/hp_space/hp_space.py index 09d87112abe632cd749cb5d20541cb1f42316248..ae2b31b779b7244c8dbb75c88fd914d97562367d 100644 --- a/nifty/spaces/hp_space/hp_space.py +++ b/nifty/spaces/hp_space/hp_space.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np @@ -84,6 +84,9 @@ class HPSpace(Space): # ---Mandatory properties and methods--- + def __repr__(self): + return ("HPSpace(nside=%r)" % self.nside) + @property def harmonic(self): return False diff --git a/nifty/spaces/lm_space/__init__.py b/nifty/spaces/lm_space/__init__.py index 029ba8ae93973814473370227d9b2222c884a94d..e43aeaa0528e5840f03ff78c86ccc1af2035d16c 100644 --- a/nifty/spaces/lm_space/__init__.py +++ b/nifty/spaces/lm_space/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,5 +10,10 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from lm_space import LMSpace diff --git a/nifty/spaces/lm_space/lm_space.py b/nifty/spaces/lm_space/lm_space.py index 5cadf785bdb0bd89947d704242fb0fea21db56ce..bd5248e76b63e180a9e33d86bafc105b819714da 100644 --- a/nifty/spaces/lm_space/lm_space.py +++ b/nifty/spaces/lm_space/lm_space.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from __future__ import division @@ -91,17 +91,29 @@ class LMSpace(Space): def hermitian_decomposition(self, x, axes=None, preserve_gaussian_variance=False): - hermitian_part = x.copy_empty() - anti_hermitian_part = x.copy_empty() - hermitian_part[:] = x.real - anti_hermitian_part[:] = x.imag * 1j + if issubclass(x.dtype.type, np.complexfloating): + hermitian_part = x.copy_empty() + anti_hermitian_part = x.copy_empty() + hermitian_part[:] = x.real + anti_hermitian_part[:] = x.imag * 1j + if preserve_gaussian_variance: + hermitian_part *= np.sqrt(2) + anti_hermitian_part *= np.sqrt(2) + else: + hermitian_part = x.copy() + anti_hermitian_part = x.copy_empty() + anti_hermitian_part.val[:] = 0 + return (hermitian_part, anti_hermitian_part) - def hermitian_fixed_points(self): - return None +# def hermitian_fixed_points(self): +# return None # ---Mandatory properties and methods--- + def __repr__(self): + return ("LMSpace(lmax=%r)" % self.lmax) + @property def harmonic(self): return True diff --git a/nifty/spaces/power_space/__init__.py b/nifty/spaces/power_space/__init__.py index fd032cf8184368dffb30534d9aa182e8c829ebca..cad1d25cf32750eb271d1a83dc3eb9d981c35648 100644 --- a/nifty/spaces/power_space/__init__.py +++ b/nifty/spaces/power_space/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from power_space import PowerSpace from power_index_factory import PowerIndexFactory \ No newline at end of file diff --git a/nifty/spaces/power_space/power_index_factory.py b/nifty/spaces/power_space/power_index_factory.py index ab14e5662f2ec221d0cd652e71b8809be6e54cb0..8caeee21d36db0df4767334b4d70bc9101091ec7 100644 --- a/nifty/spaces/power_space/power_index_factory.py +++ b/nifty/spaces/power_space/power_index_factory.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from power_indices import PowerIndices diff --git a/nifty/spaces/power_space/power_indices.py b/nifty/spaces/power_space/power_indices.py index bff17e0ec6b4a073c0af4aba2c26d8e7124c264b..9841a005cce5ec31d0088a9a5a546c53e127c4a1 100644 --- a/nifty/spaces/power_space/power_indices.py +++ b/nifty/spaces/power_space/power_indices.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np from d2o import distributed_data_object,\ diff --git a/nifty/spaces/power_space/power_space.py b/nifty/spaces/power_space/power_space.py index ce56812a48db1ddc2751f60dbdd1f60cb101e77c..9be622643e9075c3173e4f587648e5b6b3ec8378 100644 --- a/nifty/spaces/power_space/power_space.py +++ b/nifty/spaces/power_space/power_space.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import numpy as np @@ -149,6 +149,13 @@ class PowerSpace(Space): # ---Mandatory properties and methods--- + def __repr__(self): + return ("PowerSpace(harmonic_partner=%r, distribution_strategy=%r, " + "logarithmic=%r, nbin=%r, binbounds=%r)" + % (self.harmonic_partner, self.pindex.distribution_strategy, + self.config['logarithmic'], self.config['nbin'], + self.config['binbounds'])) + @property def harmonic(self): return True @@ -261,6 +268,7 @@ class PowerSpace(Space): hdf5_group.attrs['nbin'] = str(self.config["nbin"]) hdf5_group.attrs['binbounds'] = str(self.config["binbounds"]) + #MR FIXME: why not "return None" as happens everywhere else? return { 'harmonic_partner': self.harmonic_partner, 'pindex': self.pindex, diff --git a/nifty/spaces/rg_space/__init__.py b/nifty/spaces/rg_space/__init__.py index b5efcf9fdc00044109fd94e419e23668a8168fc2..e90fb343aab0f5ffc1d51e9620e475c0457bbc75 100644 --- a/nifty/spaces/rg_space/__init__.py +++ b/nifty/spaces/rg_space/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,5 +10,10 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from rg_space import RGSpace diff --git a/nifty/spaces/rg_space/rg_space.py b/nifty/spaces/rg_space/rg_space.py index 887e52de8431296ed9d8de35e8f7dd5259f5afde..ea70464ef707c79919da8976e2c8f084c248adfb 100644 --- a/nifty/spaces/rg_space/rg_space.py +++ b/nifty/spaces/rg_space/rg_space.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. """ .. __ ____ __ @@ -52,10 +52,10 @@ class RGSpace(Space): ---------- shape : {int, numpy.ndarray} Number of grid points or numbers of gridpoints along each axis. - zerocenter : {bool, numpy.ndarray}, *optional* - Whether x==0 (or k==0, respectively) is located in the center of - the grid (or the center of each axis speparately) or not. - (default: False). + zerocenter : {bool, numpy.ndarray} *optional* + Whether x==0 (or k==0, respectively) is located in the center of + the grid (or the center of each axis speparately) or not. + (default: False). distances : {float, numpy.ndarray}, *optional* Distance between two grid points along each axis (default: None). @@ -120,40 +120,32 @@ class RGSpace(Space): return (hermitian_part, anti_hermitian_part) - def hermitian_fixed_points(self): - shape = self.shape - mid_index = np.array(shape)//2 - ndlist = [2 if (shape[i] % 2 == 0) else 1 for i in xrange(len(shape))] - ndlist = tuple(ndlist) - odd_axes_list = np.array([1 if (shape[i] % 2 == 1) else 0 - for i in xrange(len(shape))]) - fixed_points = [] - for i in np.ndindex(ndlist): - fixed_points += [tuple((i+odd_axes_list) * mid_index)] - return fixed_points - def _hermitianize_correct_variance(self, hermitian_part, anti_hermitian_part, axes): # Correct the variance by multiplying sqrt(2) hermitian_part = hermitian_part * np.sqrt(2) anti_hermitian_part = anti_hermitian_part * np.sqrt(2) - # The fixed points of the point inversion must not be averaged. - # Hence one must divide out the sqrt(2) again - # -> Get the middle index of the array - mid_index = np.array(hermitian_part.shape, dtype=np.int) // 2 - dimensions = mid_index.size - # Use ndindex to iterate over all combinations of zeros and the - # mid_index in order to correct all fixed points. - if axes is None: - axes = xrange(dimensions) - - ndlist = [2 if i in axes else 1 for i in xrange(dimensions)] - ndlist = tuple(ndlist) - for i in np.ndindex(ndlist): - temp_index = tuple(i * mid_index) - hermitian_part[temp_index] /= np.sqrt(2) - anti_hermitian_part[temp_index] /= np.sqrt(2) + # If the dtype of the input is complex, the fixed points lose the power + # of their imaginary-part (or real-part, respectively). Therefore + # the factor of sqrt(2) also applies there + if not issubclass(hermitian_part.dtype.type, np.complexfloating): + # The fixed points of the point inversion must not be averaged. + # Hence one must divide out the sqrt(2) again + # -> Get the middle index of the array + mid_index = np.array(hermitian_part.shape, dtype=np.int) // 2 + dimensions = mid_index.size + # Use ndindex to iterate over all combinations of zeros and the + # mid_index in order to correct all fixed points. + if axes is None: + axes = xrange(dimensions) + + ndlist = [2 if i in axes else 1 for i in xrange(dimensions)] + ndlist = tuple(ndlist) + for i in np.ndindex(ndlist): + temp_index = tuple(i * mid_index) + hermitian_part[temp_index] /= np.sqrt(2) + anti_hermitian_part[temp_index] /= np.sqrt(2) return hermitian_part, anti_hermitian_part def _hermitianize_inverter(self, x, axes): @@ -193,6 +185,10 @@ class RGSpace(Space): # ---Mandatory properties and methods--- + def __repr__(self): + return ("RGSpace(shape=%r, zerocenter=%r, distances=%r, harmonic=%r)" + % (self.shape, self.zerocenter, self.distances, self.harmonic)) + @property def harmonic(self): return self._harmonic @@ -286,10 +282,6 @@ class RGSpace(Space): return dists def get_fft_smoothing_kernel_function(self, sigma): - - if sigma is None: - sigma = np.sqrt(2) * np.max(self.distances) - return lambda x: np.exp(-0.5 * np.pi**2 * x**2 * sigma**2) # ---Added properties and methods--- diff --git a/nifty/spaces/space/__init__.py b/nifty/spaces/space/__init__.py index 281b1c876f4817ec4aa5545ec6f2cfd12f3b4ea0..2b000a62a8a7f7d4e733a437c354d7a0f8fbd1af 100644 --- a/nifty/spaces/space/__init__.py +++ b/nifty/spaces/space/__init__.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,5 +10,10 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from space import Space diff --git a/nifty/spaces/space/space.py b/nifty/spaces/space/space.py index 84314c48cc968c41d94320d26ee0ba9c4f615d3d..dc49c0c4c1d158c3b6d20917ccd652c848299f4e 100644 --- a/nifty/spaces/space/space.py +++ b/nifty/spaces/space/space.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import abc @@ -64,12 +64,6 @@ class Space(DomainObject): @abc.abstractproperty def harmonic(self): """ Returns True if this space is a harmonic space. - - Raises - ------ - NotImplementedError - If called for this abstract class. - """ raise NotImplementedError @@ -83,12 +77,8 @@ class Space(DomainObject): float A real number representing the sum of all pixel volumes. - Raises - ------ - NotImplementedError - If called for this abstract class. - """ + raise NotImplementedError( "There is no generic volume for the Space base class.") @@ -122,11 +112,6 @@ class Space(DomainObject): distributed_data_object A d2o containing the distances - Raises - ------ - NotImplementedError - If called for this abstract class. - """ raise NotImplementedError( @@ -157,11 +142,6 @@ class Space(DomainObject): A smoothing operation that multiplies values with a Gaussian kernel. - Raises - ------ - NotImplementedError : - If called for this abstract class. - """ raise NotImplementedError( @@ -184,7 +164,11 @@ class Space(DomainObject): Specifies the axes of x which correspond to this space. preserve_gaussian_variance : bool *optional* - FIXME: figure out what this does + If the hermitian decomposition is done via computing the half + sums and differences of `x` and mirrored `x`, all points except the + fixed points lose half of their variance. If `x` is complex also + the lose half of their variance since the real(/imaginary) part + gets lost. Returns ------- @@ -192,16 +176,6 @@ class Space(DomainObject): A tuple of two distributed_data_objects, the first being the hermitian and the second the anti-hermitian part of x. - Raises - ------ - NotImplementedError - If called for this abstract class. - """ raise NotImplementedError - - def __repr__(self): - string = "" - string += str(type(self)) + "\n" - return string diff --git a/nifty/sugar.py b/nifty/sugar.py index f34f4198dd96768cb1bb912c1ec62b0eb499b779..c567738151301e13ac8320122f7558a71511f7b8 100644 --- a/nifty/sugar.py +++ b/nifty/sugar.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,31 +10,51 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from nifty import PowerSpace,\ Field,\ - DiagonalOperator,\ - FFTOperator + DiagonalOperator __all__ = ['create_power_operator'] def create_power_operator(domain, power_spectrum, dtype=None, distribution_strategy='not'): - if not domain.harmonic: - fft = FFTOperator(domain) - domain = fft.target[0] + """ Creates a diagonal operator with the given power spectrum. + + Constructs a diagonal operator that lives over the specified domain. + + Parameters + ---------- + domain : DomainObject + Domain over which the power operator shall live. + power_spectrum : (array-like, method) + An array-like object, or a method that implements the square root + of a power spectrum as a function of k. + dtype : type *optional* + dtype that the field holding the power spectrum shall use + (default : None). + if dtype == None: the dtype of `power_spectrum` will be used. + distribution_strategy : string *optional* + Distributed strategy to be used by the underlying d2o objects. + (default : 'not') + + Returns + ------- + DiagonalOperator : An operator that implements the given power spectrum. + + """ power_domain = PowerSpace(domain, distribution_strategy=distribution_strategy) - - fp = Field(power_domain, - val=power_spectrum, dtype=dtype, + fp = Field(power_domain, val=power_spectrum, dtype=dtype, distribution_strategy=distribution_strategy) fp **= 2 - f = fp.power_synthesize(mean=1, std=0, real_signal=False) - power_operator = DiagonalOperator(domain, diagonal=f, bare=True) - - return power_operator + return DiagonalOperator(domain, diagonal=f, bare=True) diff --git a/nifty/version.py b/nifty/version.py index 04678f84a2ed856b0ddb7c714b8e774360e7f3fd..5d993bb74978ca363353593c84a4fd4036a58ffe 100644 --- a/nifty/version.py +++ b/nifty/version.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. # Store the version here so: # 1) we don't load dependencies by storing it in __init__.py diff --git a/setup.py b/setup.py index 54dfa4ed1fe87ae803fe2a2a19e7e03d8dd15f6e..b36055e7a3bbc689e6a06bc7427d009cda943688 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from setuptools import setup, find_packages diff --git a/test/common.py b/test/common.py index 8042d8246196ef4fa535943c2aa360b9ee0495c1..797ed80642e6eda2788562589a4d06d46c7c1cc2 100644 --- a/test/common.py +++ b/test/common.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import d2o import numpy as np diff --git a/test/test_field.py b/test/test_field.py index 11c73cee6f74183016b4953297371d82aad64e9f..a2b0491c4c4b0aaaa9b3bd0c2caebf6ab55fbd71 100644 --- a/test/test_field.py +++ b/test/test_field.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import unittest diff --git a/test/test_operators/test_diagonal_operator.py b/test/test_operators/test_diagonal_operator.py index 90f1ef7c4ac2f095d400d4d60e51314b8324cc08..ef953fa0602b50f923d6566fbebe6205f3f8e44c 100644 --- a/test/test_operators/test_diagonal_operator.py +++ b/test/test_operators/test_diagonal_operator.py @@ -106,6 +106,7 @@ class DiagonalOperator_Tests(unittest.TestCase): assert_allclose(trace_op, np.sum(1./diag.val.get_full_data())) @expand(product(spaces, [True, False])) + #MR FIXME: what if any diagonal element <=0? def test_trace_log(self, space, copy): diag = Field.from_random('normal', domain=space) D = DiagonalOperator(space, diagonal=diag, copy=copy) @@ -127,8 +128,9 @@ class DiagonalOperator_Tests(unittest.TestCase): assert_allclose(inv_det, 1./D.determinant()) @expand(product(spaces, [True, False], [True, False])) + #MR FIXME: what if determinant <=0? def test_log_determinant(self, space, bare, copy): diag = Field.from_random('normal', domain=space) D = DiagonalOperator(space, diagonal=diag, bare=bare, copy=copy) log_det = D.log_determinant() - assert_allclose(log_det, np.log(D.determinant())) \ No newline at end of file + assert_allclose(log_det, np.log(D.determinant())) diff --git a/test/test_operators/test_fft_operator.py b/test/test_operators/test_fft_operator.py index c63f91bc847b296bcda9cc3269aeb72330ba3fb4..1f55c645e793da8477a03a7bbc55ba9a384cde13 100644 --- a/test/test_operators/test_fft_operator.py +++ b/test/test_operators/test_fft_operator.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import unittest import numpy as np diff --git a/test/test_operators/test_smoothing_operator.py b/test/test_operators/test_smoothing_operator.py index ec582e6d9c627784f4664dc1d0b08c72bfab3103..f5c107b81b3db548a67e9959b262a5ec4881c61f 100644 --- a/test/test_operators/test_smoothing_operator.py +++ b/test/test_operators/test_smoothing_operator.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import unittest import numpy as np @@ -36,9 +36,6 @@ def _get_rtol(tp): else: return 1e-5 -from itertools import product -from test.common import expand - class SmoothingOperator_Tests(unittest.TestCase): spaces = [RGSpace(100)] diff --git a/test/test_serialization.py b/test/test_serialization.py index 2cea198cff81db506cc65df695da647d9892c531..37e77167e7437b3f2943c86d160d6f31ca76356a 100644 --- a/test/test_serialization.py +++ b/test/test_serialization.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import unittest diff --git a/test/test_spaces/test_gl_space.py b/test/test_spaces/test_gl_space.py index c37c8218f3b2086a04a6c988f42e53f96513b897..3d0a053ca1a473a35904687d9385894f70a5b911 100644 --- a/test/test_spaces/test_gl_space.py +++ b/test/test_spaces/test_gl_space.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import unittest import numpy as np diff --git a/test/test_spaces/test_hp_space.py b/test/test_spaces/test_hp_space.py index e68b93ee750b9d87d2ec680f9f9b904930b391e5..790f505f4588e38d8b0bee461961f671a484fa99 100644 --- a/test/test_spaces/test_hp_space.py +++ b/test/test_spaces/test_hp_space.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import unittest import numpy as np diff --git a/test/test_spaces/test_interface.py b/test/test_spaces/test_interface.py index 927d68df8aff2fa8418e846e84df06fffc3ed358..49c66c0a47984d4edf90ee0f3378ab398b2d558f 100644 --- a/test/test_spaces/test_interface.py +++ b/test/test_spaces/test_interface.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,17 +10,23 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import unittest import numpy as np +from numpy.testing import assert_, assert_equal from itertools import product from types import LambdaType -from numpy.testing import assert_, assert_raises, assert_equal -from nifty import LMSpace, GLSpace, HPSpace -from nifty.config import dependency_injector as di from test.common import expand, generate_spaces, generate_harmonic_spaces +from d2o import distributed_data_object +from nifty.spaces import * + class SpaceInterfaceTests(unittest.TestCase): @expand(product(generate_spaces(), [ @@ -34,28 +35,17 @@ class SpaceInterfaceTests(unittest.TestCase): ['dim', int], ['total_volume', np.float]])) def test_property_ret_type(self, space, attr_expected_type): - assert_( - isinstance(getattr( - space, - attr_expected_type[0] - ), attr_expected_type[1]) - ) + assert_(isinstance(getattr(space, attr_expected_type[0]), + attr_expected_type[1])) @expand(product(generate_harmonic_spaces(), [ - ['get_fft_smoothing_kernel_function', None, LambdaType], + ['get_distance_array', 'not', distributed_data_object], ['get_fft_smoothing_kernel_function', 2.0, LambdaType], ])) def test_method_ret_type(self, space, method_expected_type): - getattr( - space, method_expected_type[0])(*method_expected_type[1:-1]) - - assert_equal( - type(getattr( - space, - method_expected_type[0])(*method_expected_type[1:-1]) - ), - method_expected_type[-1] - ) + assert_(type(getattr(space, method_expected_type[0])( + *method_expected_type[1:-1])) is + method_expected_type[-1]) @expand([[space] for space in generate_spaces()]) def test_copy(self, space): @@ -63,3 +53,7 @@ class SpaceInterfaceTests(unittest.TestCase): assert_(space is not space.copy()) # make sure contents are the same assert_equal(space, space.copy()) + + @expand([[space] for space in generate_spaces()]) + def test_repr(self, space): + assert_(space == eval(space.__repr__())) diff --git a/test/test_spaces/test_lm_space.py b/test/test_spaces/test_lm_space.py index b058a357f5e7724f89b0a9b2414319751ce25c10..15a81525b2f2a9c9b6136586c8384b6114b0108e 100644 --- a/test/test_spaces/test_lm_space.py +++ b/test/test_spaces/test_lm_space.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. import unittest import numpy as np diff --git a/test/test_spaces/test_power_space.py b/test/test_spaces/test_power_space.py index 86b27d1221ded8bd503e9f4105c616e5485d4fee..f1fcfdf688e85481524fe0294163664a8713e89d 100644 --- a/test/test_spaces/test_power_space.py +++ b/test/test_spaces/test_power_space.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from __future__ import division diff --git a/test/test_spaces/test_rg_space.py b/test/test_spaces/test_rg_space.py index ae468c1870145856c5f55f421197b1b8ef7989e8..e3f950c71b6b236d8cc7f04a022d195bbf882936 100644 --- a/test/test_spaces/test_rg_space.py +++ b/test/test_spaces/test_rg_space.py @@ -1,8 +1,3 @@ -# NIFTy -# Copyright (C) 2017 Theo Steininger -# -# Author: Theo Steininger -# # 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 @@ -15,6 +10,11 @@ # # 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-2017 Max-Planck-Society +# +# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik +# and financially supported by the Studienstiftung des deutschen Volkes. from __future__ import division