From 1318ccc8584cda177dbf905b8f17c206216626c4 Mon Sep 17 00:00:00 2001 From: theos Date: Sat, 23 Jul 2016 00:42:48 +0200 Subject: [PATCH] Moved nifty source code into nifty subdirectory. Adapted imports and setup.py to changes. --- d2o_config | 6 - __init__.py => nifty/__init__.py | 13 +- {config => nifty/config}/__init__.py | 0 {config => nifty/config}/d2o_config.py | 0 {config => nifty/config}/nifty_about.py | 0 {config => nifty/config}/nifty_config.py | 0 {demos => nifty/demos}/__init__.py | 0 {demos => nifty/demos}/demo_excaliwir.py | 0 {demos => nifty/demos}/demo_faraday.py | 0 {demos => nifty/demos}/demo_faraday_map.npy | Bin {demos => nifty/demos}/demo_tomography.py | 0 {demos => nifty/demos}/demo_wf1.py | 0 {demos => nifty/demos}/demo_wf2.py | 0 {demos => nifty/demos}/demo_wf3.py | 0 {demos => nifty/demos}/demos_core.py | 0 {dummys => nifty/dummys}/__init__.py | 0 {dummys => nifty/dummys}/gfft_dummy.py | 0 field.py => nifty/field.py | 2 +- .../field_types}/__init__.py | 0 .../field_types}/base_field_type.py | 0 .../field_types}/field_array.py | 0 nifty_cmaps.py => nifty/nifty_cmaps.py | 0 nifty_random.py => nifty/nifty_random.py | 0 .../nifty_simple_math.py | 0 .../nifty_utilities.py | 0 {operators => nifty/operators}/__init__.py | 0 .../operators}/nifty_minimization.py | 0 .../operators}/nifty_operators.py | 2 +- .../operators}/nifty_probing.py | 2 +- .../power_conversion.py | 171 +++- {spaces => nifty/spaces}/__init__.py | 8 +- {spaces => nifty/spaces}/gl_space/__init__.py | 0 {spaces => nifty/spaces}/gl_space/gl_space.py | 10 +- .../spaces}/gl_space/gl_space_paradict.py | 0 {spaces => nifty/spaces}/hp_space/__init__.py | 0 {spaces => nifty/spaces}/hp_space/hp_space.py | 7 +- .../spaces}/hp_space/hp_space_paradict.py | 0 nifty/spaces/lm_space/__init__.py | 7 + {spaces => nifty/spaces}/lm_space/lm_space.py | 12 +- .../spaces}/lm_space/lm_space_paradict.py | 0 .../spaces}/power_space/__init__.py | 0 .../power_space/power_index_factory.py | 0 .../spaces}/power_space/power_indices.py | 0 .../spaces}/power_space/power_space.py | 2 +- .../power_space/power_space_paradict.py | 0 {spaces => nifty/spaces}/rg_space/__init__.py | 3 - {spaces => nifty/spaces}/rg_space/rg_space.py | 10 +- .../spaces}/rg_space/rg_space_paradict.py | 0 {spaces => nifty/spaces}/space/__init__.py | 0 {spaces => nifty/spaces}/space/space.py | 0 .../spaces}/space/space_paradict.py | 0 {test => nifty/test}/hdf5_init_test.hdf5 | Bin .../hdf5_test_folder/hdf5_init_test.hdf5 | Bin .../hdf5_test_folder/hdf5_init_test_2.hdf5 | Bin {test => nifty/test}/test_nifty_field.py | 0 {test => nifty/test}/test_nifty_operators.py | 0 {test => nifty/test}/test_nifty_spaces.py | 0 {test => nifty/test}/test_nifty_transforms.py | 0 {test => nifty/test}/test_nifty_utilities.py | 0 .../transformations}/__init__.py | 0 .../transformations}/gllmtransformation.py | 0 .../transformations}/hplmtransformation.py | 0 .../transformations}/lmgltransformation.py | 0 .../transformations}/lmhptransformation.py | 0 .../transformations}/rg_transforms.py | 0 .../transformations}/rgrgtransformation.py | 0 .../transformations}/transformation.py | 0 .../transformation_factory.py | 3 +- version.py => nifty/version.py | 0 nifty_config | 9 - nifty_paradict.py | 221 ------ nifty_power_indices.py | 736 ------------------ pickling.py | 54 -- setup.py | 12 +- spaces/lm_space/__init__.py | 8 - spaces/lm_space/nifty_power_conversion_lm.py | 153 ---- 76 files changed, 192 insertions(+), 1259 deletions(-) delete mode 100644 d2o_config rename __init__.py => nifty/__init__.py (81%) rename {config => nifty/config}/__init__.py (100%) rename {config => nifty/config}/d2o_config.py (100%) rename {config => nifty/config}/nifty_about.py (100%) rename {config => nifty/config}/nifty_config.py (100%) rename {demos => nifty/demos}/__init__.py (100%) rename {demos => nifty/demos}/demo_excaliwir.py (100%) rename {demos => nifty/demos}/demo_faraday.py (100%) rename {demos => nifty/demos}/demo_faraday_map.npy (100%) rename {demos => nifty/demos}/demo_tomography.py (100%) rename {demos => nifty/demos}/demo_wf1.py (100%) rename {demos => nifty/demos}/demo_wf2.py (100%) rename {demos => nifty/demos}/demo_wf3.py (100%) rename {demos => nifty/demos}/demos_core.py (100%) rename {dummys => nifty/dummys}/__init__.py (100%) rename {dummys => nifty/dummys}/gfft_dummy.py (100%) rename field.py => nifty/field.py (99%) rename {field_types => nifty/field_types}/__init__.py (100%) rename {field_types => nifty/field_types}/base_field_type.py (100%) rename {field_types => nifty/field_types}/field_array.py (100%) rename nifty_cmaps.py => nifty/nifty_cmaps.py (100%) rename nifty_random.py => nifty/nifty_random.py (100%) rename nifty_simple_math.py => nifty/nifty_simple_math.py (100%) rename nifty_utilities.py => nifty/nifty_utilities.py (100%) rename {operators => nifty/operators}/__init__.py (100%) rename {operators => nifty/operators}/nifty_minimization.py (100%) rename {operators => nifty/operators}/nifty_operators.py (99%) rename {operators => nifty/operators}/nifty_probing.py (99%) rename spaces/rg_space/nifty_power_conversion_rg.py => nifty/power_conversion.py (52%) rename {spaces => nifty/spaces}/__init__.py (56%) rename {spaces => nifty/spaces}/gl_space/__init__.py (100%) rename {spaces => nifty/spaces}/gl_space/gl_space.py (99%) rename {spaces => nifty/spaces}/gl_space/gl_space_paradict.py (100%) rename {spaces => nifty/spaces}/hp_space/__init__.py (100%) rename {spaces => nifty/spaces}/hp_space/hp_space.py (99%) rename {spaces => nifty/spaces}/hp_space/hp_space_paradict.py (100%) create mode 100644 nifty/spaces/lm_space/__init__.py rename {spaces => nifty/spaces}/lm_space/lm_space.py (99%) rename {spaces => nifty/spaces}/lm_space/lm_space_paradict.py (100%) rename {spaces => nifty/spaces}/power_space/__init__.py (100%) rename {spaces => nifty/spaces}/power_space/power_index_factory.py (100%) rename {spaces => nifty/spaces}/power_space/power_indices.py (100%) rename {spaces => nifty/spaces}/power_space/power_space.py (99%) rename {spaces => nifty/spaces}/power_space/power_space_paradict.py (100%) rename {spaces => nifty/spaces}/rg_space/__init__.py (87%) rename {spaces => nifty/spaces}/rg_space/rg_space.py (99%) rename {spaces => nifty/spaces}/rg_space/rg_space_paradict.py (100%) rename {spaces => nifty/spaces}/space/__init__.py (100%) rename {spaces => nifty/spaces}/space/space.py (100%) rename {spaces => nifty/spaces}/space/space_paradict.py (100%) rename {test => nifty/test}/hdf5_init_test.hdf5 (100%) rename {test => nifty/test}/hdf5_test_folder/hdf5_init_test.hdf5 (100%) rename {test => nifty/test}/hdf5_test_folder/hdf5_init_test_2.hdf5 (100%) rename {test => nifty/test}/test_nifty_field.py (100%) rename {test => nifty/test}/test_nifty_operators.py (100%) rename {test => nifty/test}/test_nifty_spaces.py (100%) rename {test => nifty/test}/test_nifty_transforms.py (100%) rename {test => nifty/test}/test_nifty_utilities.py (100%) rename {transformations => nifty/transformations}/__init__.py (100%) rename {transformations => nifty/transformations}/gllmtransformation.py (100%) rename {transformations => nifty/transformations}/hplmtransformation.py (100%) rename {transformations => nifty/transformations}/lmgltransformation.py (100%) rename {transformations => nifty/transformations}/lmhptransformation.py (100%) rename {transformations => nifty/transformations}/rg_transforms.py (100%) rename {transformations => nifty/transformations}/rgrgtransformation.py (100%) rename {transformations => nifty/transformations}/transformation.py (100%) rename {transformations => nifty/transformations}/transformation_factory.py (96%) rename version.py => nifty/version.py (100%) delete mode 100644 nifty_config delete mode 100644 nifty_paradict.py delete mode 100644 nifty_power_indices.py delete mode 100644 pickling.py delete mode 100644 spaces/lm_space/__init__.py delete mode 100644 spaces/lm_space/nifty_power_conversion_lm.py diff --git a/d2o_config b/d2o_config deleted file mode 100644 index 78081536..00000000 --- a/d2o_config +++ /dev/null @@ -1,6 +0,0 @@ -[DEFAULT] -mpi_module = MPI -mpi_init_checks = False -default_distribution_strategy = fftw -default_comm = COMM_WORLD - diff --git a/__init__.py b/nifty/__init__.py similarity index 81% rename from __init__.py rename to nifty/__init__.py index 387bc04c..7124c420 100644 --- a/__init__.py +++ b/nifty/__init__.py @@ -39,11 +39,10 @@ from d2o import distributed_data_object, d2o_librarian from nifty_cmaps import ncmap from field import Field -from space import Space # this line exists for compatibility reasons # TODO: Remove this once the transition to field types is done. -from space import Space as point_space +from spaces.space import Space as point_space from nifty_random import random from nifty_simple_math import * @@ -56,15 +55,7 @@ from operators import * from spaces import * - from demos import get_demo_dir -from pickling import _pickle_method, _unpickle_method #import pyximport; pyximport.install(pyimport = True) -from transformations import TransformationFactory,\ - GLLMTransformation,\ - HPLMTransformation,\ - LMGLTransformation,\ - LMHPTransformation,\ - RGRGTransformation - +from transformations import * \ No newline at end of file diff --git a/config/__init__.py b/nifty/config/__init__.py similarity index 100% rename from config/__init__.py rename to nifty/config/__init__.py diff --git a/config/d2o_config.py b/nifty/config/d2o_config.py similarity index 100% rename from config/d2o_config.py rename to nifty/config/d2o_config.py diff --git a/config/nifty_about.py b/nifty/config/nifty_about.py similarity index 100% rename from config/nifty_about.py rename to nifty/config/nifty_about.py diff --git a/config/nifty_config.py b/nifty/config/nifty_config.py similarity index 100% rename from config/nifty_config.py rename to nifty/config/nifty_config.py diff --git a/demos/__init__.py b/nifty/demos/__init__.py similarity index 100% rename from demos/__init__.py rename to nifty/demos/__init__.py diff --git a/demos/demo_excaliwir.py b/nifty/demos/demo_excaliwir.py similarity index 100% rename from demos/demo_excaliwir.py rename to nifty/demos/demo_excaliwir.py diff --git a/demos/demo_faraday.py b/nifty/demos/demo_faraday.py similarity index 100% rename from demos/demo_faraday.py rename to nifty/demos/demo_faraday.py diff --git a/demos/demo_faraday_map.npy b/nifty/demos/demo_faraday_map.npy similarity index 100% rename from demos/demo_faraday_map.npy rename to nifty/demos/demo_faraday_map.npy diff --git a/demos/demo_tomography.py b/nifty/demos/demo_tomography.py similarity index 100% rename from demos/demo_tomography.py rename to nifty/demos/demo_tomography.py diff --git a/demos/demo_wf1.py b/nifty/demos/demo_wf1.py similarity index 100% rename from demos/demo_wf1.py rename to nifty/demos/demo_wf1.py diff --git a/demos/demo_wf2.py b/nifty/demos/demo_wf2.py similarity index 100% rename from demos/demo_wf2.py rename to nifty/demos/demo_wf2.py diff --git a/demos/demo_wf3.py b/nifty/demos/demo_wf3.py similarity index 100% rename from demos/demo_wf3.py rename to nifty/demos/demo_wf3.py diff --git a/demos/demos_core.py b/nifty/demos/demos_core.py similarity index 100% rename from demos/demos_core.py rename to nifty/demos/demos_core.py diff --git a/dummys/__init__.py b/nifty/dummys/__init__.py similarity index 100% rename from dummys/__init__.py rename to nifty/dummys/__init__.py diff --git a/dummys/gfft_dummy.py b/nifty/dummys/gfft_dummy.py similarity index 100% rename from dummys/gfft_dummy.py rename to nifty/dummys/gfft_dummy.py diff --git a/field.py b/nifty/field.py similarity index 99% rename from field.py rename to nifty/field.py index 8cd53cbe..a7a87de4 100644 --- a/field.py +++ b/nifty/field.py @@ -12,7 +12,7 @@ from nifty.config import about, \ from nifty.field_types import FieldType,\ FieldArray -from nifty.space import Space +from nifty.spaces.space import Space import nifty.nifty_utilities as utilities from nifty_random import random diff --git a/field_types/__init__.py b/nifty/field_types/__init__.py similarity index 100% rename from field_types/__init__.py rename to nifty/field_types/__init__.py diff --git a/field_types/base_field_type.py b/nifty/field_types/base_field_type.py similarity index 100% rename from field_types/base_field_type.py rename to nifty/field_types/base_field_type.py diff --git a/field_types/field_array.py b/nifty/field_types/field_array.py similarity index 100% rename from field_types/field_array.py rename to nifty/field_types/field_array.py diff --git a/nifty_cmaps.py b/nifty/nifty_cmaps.py similarity index 100% rename from nifty_cmaps.py rename to nifty/nifty_cmaps.py diff --git a/nifty_random.py b/nifty/nifty_random.py similarity index 100% rename from nifty_random.py rename to nifty/nifty_random.py diff --git a/nifty_simple_math.py b/nifty/nifty_simple_math.py similarity index 100% rename from nifty_simple_math.py rename to nifty/nifty_simple_math.py diff --git a/nifty_utilities.py b/nifty/nifty_utilities.py similarity index 100% rename from nifty_utilities.py rename to nifty/nifty_utilities.py diff --git a/operators/__init__.py b/nifty/operators/__init__.py similarity index 100% rename from operators/__init__.py rename to nifty/operators/__init__.py diff --git a/operators/nifty_minimization.py b/nifty/operators/nifty_minimization.py similarity index 100% rename from operators/nifty_minimization.py rename to nifty/operators/nifty_minimization.py diff --git a/operators/nifty_operators.py b/nifty/operators/nifty_operators.py similarity index 99% rename from operators/nifty_operators.py rename to nifty/operators/nifty_operators.py index f8dfa50d..d3d4345e 100644 --- a/operators/nifty_operators.py +++ b/nifty/operators/nifty_operators.py @@ -23,7 +23,7 @@ from __future__ import division import numpy as np from nifty.config import about from nifty.field import Field -from nifty.space import Space +from nifty.spaces.space import Space from nifty_minimization import conjugate_gradient from nifty_probing import trace_prober,\ diff --git a/operators/nifty_probing.py b/nifty/operators/nifty_probing.py similarity index 99% rename from operators/nifty_probing.py rename to nifty/operators/nifty_probing.py index d86745b7..c20c9170 100644 --- a/operators/nifty_probing.py +++ b/nifty/operators/nifty_probing.py @@ -22,7 +22,7 @@ from __future__ import division from nifty.config import about -from nifty.space import Space +from nifty.spaces.space import Space from nifty.field import Field from nifty.nifty_utilities import direct_vdot diff --git a/spaces/rg_space/nifty_power_conversion_rg.py b/nifty/power_conversion.py similarity index 52% rename from spaces/rg_space/nifty_power_conversion_rg.py rename to nifty/power_conversion.py index 8255195f..ef0a4aed 100644 --- a/spaces/rg_space/nifty_power_conversion_rg.py +++ b/nifty/power_conversion.py @@ -1,28 +1,155 @@ -# NIFTY (Numerical Information Field Theory) has been developed at the -# Max-Planck-Institute for Astrophysics. -# -# Copyright (C) 2014 Max-Planck-Society -# -# Author: Maksim Greiner, Marco Selig -# Project homepage: -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - +## NIFTY (Numerical Information Field Theory) has been developed at the +## Max-Planck-Institute for Astrophysics. +## +## Copyright (C) 2015 Max-Planck-Society +## +## Author: Marco Selig +## Project homepage: +## +## This program is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +## See the GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see . import numpy as np +from numpy import pi from nifty.config import about from nifty.field import Field +from nifty.nifty_simple_math import sqrt, exp, log + + +def power_backward_conversion_lm(k_space, p, mean=None): + """ + This function is designed to convert a theoretical/statistical power + spectrum of a log-normal field to the theoretical power spectrum of + the underlying Gaussian field. + The function only works for power spectra defined for lm_spaces + + Parameters + ---------- + k_space : nifty.rg_space, + a regular grid space with the attribute `Fourier = True` + p : np.array, + the power spectrum of the log-normal field. + Needs to have the same number of entries as + `k_space.get_power_indices()[0]` + mean : float, *optional* + specifies the mean of the log-normal field. If `mean` is not + specified the function will use the monopole of the power spectrum. + If it is specified the function will NOT use the monopole of the + spectrum. (default: None) + WARNING: a mean that is too low can violate positive definiteness + of the log-normal field. In this case the function produces an + error. + + Returns + ------- + mean : float, + the recovered mean of the underlying Gaussian distribution. + p1 : np.array, + the power spectrum of the underlying Gaussian field, where the + monopole has been set to zero. Eventual monopole power has been + shifted to the mean. + + References + ---------- + .. [#] M. Greiner and T.A. Ensslin, "Log-transforming the matter power spectrum"; + `arXiv:1312.1354 `_ + """ + + p = np.copy(p) + if(mean is not None): + p[0] = 4*pi*mean**2 + + klen = k_space.get_power_indices()[0] + C_0_Omega = Field(k_space,val=0) + C_0_Omega.val[:len(klen)] = p*sqrt(2*klen+1)/sqrt(4*pi) + C_0_Omega = C_0_Omega.transform() + + if(np.any(C_0_Omega.val<0.)): + raise ValueError(about._errors.cstring("ERROR: spectrum or mean incompatible with positive definiteness.\n Try increasing the mean.")) + return None + + lC = log(C_0_Omega) + + Z = lC.transform() + + spec = Z.val[:len(klen)] + + mean = (spec[0]-0.5*sqrt(4*pi)*log((p*(2*klen+1)/(4*pi)).sum()))/sqrt(4*pi) + + spec[0] = 0. + + spec = spec*sqrt(4*pi)/sqrt(2*klen+1) + + spec = np.real(spec) + + if(np.any(spec<0.)): + spec = spec*(spec>0.) + about.warnings.cprint("WARNING: negative modes set to zero.") + + return mean.real,spec + + +def power_forward_conversion_lm(k_space,p,mean=0): + """ + This function is designed to convert a theoretical/statistical power + spectrum of a Gaussian field to the theoretical power spectrum of + the exponentiated field. + The function only works for power spectra defined for lm_spaces + + Parameters + ---------- + k_space : nifty.rg_space, + a regular grid space with the attribute `Fourier = True` + p : np.array, + the power spectrum of the Gaussian field. + Needs to have the same number of entries as + `k_space.get_power_indices()[0]` + m : float, *optional* + specifies the mean of the Gaussian field (default: 0). + + Returns + ------- + p1 : np.array, + the power spectrum of the exponentiated Gaussian field. + + References + ---------- + .. [#] M. Greiner and T.A. Ensslin, "Log-transforming the matter power spectrum"; + `arXiv:1312.1354 `_ + """ + m = mean + klen = k_space.get_power_indices()[0] + C_0_Omega = Field(k_space,val=0) + C_0_Omega.val[:len(klen)] = p*sqrt(2*klen+1)/sqrt(4*pi) + C_0_Omega = C_0_Omega.transform() + + C_0_0 = (p*(2*klen+1)/(4*pi)).sum() + + exC = exp(C_0_Omega+C_0_0+2*m) + + Z = exC.transform() + + spec = Z.val[:len(klen)] + + spec = spec*sqrt(4*pi)/sqrt(2*klen+1) + + spec = np.real(spec) + + if(np.any(spec<0.)): + spec = spec*(spec>0.) + about.warnings.cprint("WARNING: negative modes set to zero.") + + return spec def power_backward_conversion_rg(k_space, p, mean=None, bare=True): @@ -181,4 +308,4 @@ def power_forward_conversion_rg(k_space, p, mean=0, bare=True): if bare: new_spec /= weight - return new_spec.real + return new_spec.real \ No newline at end of file diff --git a/spaces/__init__.py b/nifty/spaces/__init__.py similarity index 56% rename from spaces/__init__.py rename to nifty/spaces/__init__.py index 28089919..08849905 100644 --- a/spaces/__init__.py +++ b/nifty/spaces/__init__.py @@ -7,17 +7,13 @@ from hp_space import HPSpace,\ HPSpaceParadict from lm_space import LMSpace,\ - LMSpaceParadict,\ - power_backward_conversion_lm,\ - power_forward_conversion_lm + LMSpaceParadict from power_space import PowerSpace,\ PowerSpaceParadict from rg_space import RGSpace,\ - RGSpaceParadict,\ - power_backward_conversion_rg,\ - power_forward_conversion_rg + RGSpaceParadict from space import Space,\ SpaceParadict diff --git a/spaces/gl_space/__init__.py b/nifty/spaces/gl_space/__init__.py similarity index 100% rename from spaces/gl_space/__init__.py rename to nifty/spaces/gl_space/__init__.py diff --git a/spaces/gl_space/gl_space.py b/nifty/spaces/gl_space/gl_space.py similarity index 99% rename from spaces/gl_space/gl_space.py rename to nifty/spaces/gl_space/gl_space.py index 387e2c98..94d3bc4f 100644 --- a/spaces/gl_space/gl_space.py +++ b/nifty/spaces/gl_space/gl_space.py @@ -7,9 +7,9 @@ from matplotlib.ticker import LogFormatter as lf from d2o import STRATEGIES as DISTRIBUTION_STRATEGIES -from nifty.lm.lm_space import LMSpace +from nifty.spaces.lm_space import LMSpace -from nifty.space import Space +from nifty.spaces.space import Space from nifty.config import about,\ nifty_configuration as gc,\ dependency_injector as gdi @@ -570,6 +570,8 @@ class GLSpace(Space): the figure is not saved (default: False). """ + from nifty.field import Field + try: x = x.get_full_data() except AttributeError: @@ -602,11 +604,11 @@ class GLSpace(Space): if(isinstance(other, tuple)): other = list(other) for ii in xrange(len(other)): - if(isinstance(other[ii], field)): + if(isinstance(other[ii], Field)): other[ii] = other[ii].power(**kwargs) else: other[ii] = self.enforce_power(other[ii]) - elif(isinstance(other, field)): + elif(isinstance(other, Field)): other = [other.power(**kwargs)] else: other = [self.enforce_power(other)] diff --git a/spaces/gl_space/gl_space_paradict.py b/nifty/spaces/gl_space/gl_space_paradict.py similarity index 100% rename from spaces/gl_space/gl_space_paradict.py rename to nifty/spaces/gl_space/gl_space_paradict.py diff --git a/spaces/hp_space/__init__.py b/nifty/spaces/hp_space/__init__.py similarity index 100% rename from spaces/hp_space/__init__.py rename to nifty/spaces/hp_space/__init__.py diff --git a/spaces/hp_space/hp_space.py b/nifty/spaces/hp_space/hp_space.py similarity index 99% rename from spaces/hp_space/hp_space.py rename to nifty/spaces/hp_space/hp_space.py index 21dc5967..1c22f9f5 100644 --- a/spaces/hp_space/hp_space.py +++ b/nifty/spaces/hp_space/hp_space.py @@ -38,10 +38,9 @@ import pylab as pl from d2o import STRATEGIES as DISTRIBUTION_STRATEGIES -from nifty.lm.lm_space import LMSpace +from nifty.spaces.lm_space import LMSpace -from nifty.space import Space -from nifty.field import Field +from nifty.spaces.space import Space from nifty.config import about,\ nifty_configuration as gc,\ @@ -523,6 +522,8 @@ class HPSpace(Space): Number of iterations performed in the HEALPix basis transformation. """ + from nifty.field import Field + try: x = x.get_full_data() except AttributeError: diff --git a/spaces/hp_space/hp_space_paradict.py b/nifty/spaces/hp_space/hp_space_paradict.py similarity index 100% rename from spaces/hp_space/hp_space_paradict.py rename to nifty/spaces/hp_space/hp_space_paradict.py diff --git a/nifty/spaces/lm_space/__init__.py b/nifty/spaces/lm_space/__init__.py new file mode 100644 index 00000000..316f3920 --- /dev/null +++ b/nifty/spaces/lm_space/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- + + +from lm_space import LMSpace +from lm_space_paradict import LMSpaceParadict + + diff --git a/spaces/lm_space/lm_space.py b/nifty/spaces/lm_space/lm_space.py similarity index 99% rename from spaces/lm_space/lm_space.py rename to nifty/spaces/lm_space/lm_space.py index 8ccddbab..fd2c65aa 100644 --- a/spaces/lm_space/lm_space.py +++ b/nifty/spaces/lm_space/lm_space.py @@ -9,7 +9,7 @@ from matplotlib.ticker import LogFormatter as lf from d2o import STRATEGIES as DISTRIBUTION_STRATEGIES -from nifty.space import Space +from nifty.spaces.space import Space from nifty.config import about,\ nifty_configuration as gc,\ @@ -285,8 +285,8 @@ class LMSpace(Space): if codomain is None: return False - from hp_space import HPSpace - from gl_space import GLSpace + from nifty.spaces.hp_space import HPSpace + from nifty.spaces.gl_space import GLSpace if not isinstance(codomain, Space): raise TypeError(about._errors.cstring( "ERROR: The given codomain must be a nifty lm_space.")) @@ -721,6 +721,8 @@ class LMSpace(Space): the figure is not saved (default: False). """ + from nifty.field import Field + try: x = x.get_full_data() except AttributeError: @@ -753,11 +755,11 @@ class LMSpace(Space): if(isinstance(other, tuple)): other = list(other) for ii in xrange(len(other)): - if(isinstance(other[ii], field)): + if(isinstance(other[ii], Field)): other[ii] = other[ii].power(**kwargs) else: other[ii] = self.enforce_power(other[ii]) - elif(isinstance(other, field)): + elif(isinstance(other, Field)): other = [other.power(**kwargs)] else: other = [self.enforce_power(other)] diff --git a/spaces/lm_space/lm_space_paradict.py b/nifty/spaces/lm_space/lm_space_paradict.py similarity index 100% rename from spaces/lm_space/lm_space_paradict.py rename to nifty/spaces/lm_space/lm_space_paradict.py diff --git a/spaces/power_space/__init__.py b/nifty/spaces/power_space/__init__.py similarity index 100% rename from spaces/power_space/__init__.py rename to nifty/spaces/power_space/__init__.py diff --git a/spaces/power_space/power_index_factory.py b/nifty/spaces/power_space/power_index_factory.py similarity index 100% rename from spaces/power_space/power_index_factory.py rename to nifty/spaces/power_space/power_index_factory.py diff --git a/spaces/power_space/power_indices.py b/nifty/spaces/power_space/power_indices.py similarity index 100% rename from spaces/power_space/power_indices.py rename to nifty/spaces/power_space/power_indices.py diff --git a/spaces/power_space/power_space.py b/nifty/spaces/power_space/power_space.py similarity index 99% rename from spaces/power_space/power_space.py rename to nifty/spaces/power_space/power_space.py index 092378ef..fa5efa5d 100644 --- a/spaces/power_space/power_space.py +++ b/nifty/spaces/power_space/power_space.py @@ -4,7 +4,7 @@ import numpy as np from d2o import STRATEGIES from nifty.config import about -from nifty.space import Space +from nifty.spaces.space import Space from power_space_paradict import PowerSpaceParadict from nifty.nifty_utilities import cast_axis_to_tuple diff --git a/spaces/power_space/power_space_paradict.py b/nifty/spaces/power_space/power_space_paradict.py similarity index 100% rename from spaces/power_space/power_space_paradict.py rename to nifty/spaces/power_space/power_space_paradict.py diff --git a/spaces/rg_space/__init__.py b/nifty/spaces/rg_space/__init__.py similarity index 87% rename from spaces/rg_space/__init__.py rename to nifty/spaces/rg_space/__init__.py index 7aebe703..d65ed839 100644 --- a/spaces/rg_space/__init__.py +++ b/nifty/spaces/rg_space/__init__.py @@ -21,6 +21,3 @@ from rg_space import RGSpace from rg_space_paradict import RGSpaceParadict -from nifty_power_conversion_rg import power_backward_conversion_rg,\ - power_forward_conversion_rg - diff --git a/spaces/rg_space/rg_space.py b/nifty/spaces/rg_space/rg_space.py similarity index 99% rename from spaces/rg_space/rg_space.py rename to nifty/spaces/rg_space/rg_space.py index 3f411096..8756d150 100644 --- a/spaces/rg_space/rg_space.py +++ b/nifty/spaces/rg_space/rg_space.py @@ -43,8 +43,7 @@ from matplotlib.ticker import LogFormatter as lf from d2o import distributed_data_object,\ STRATEGIES as DISTRIBUTION_STRATEGIES -from nifty.space import Space -from nifty.field import Field +from nifty.spaces.space import Space from nifty.config import about,\ nifty_configuration as gc,\ @@ -397,6 +396,7 @@ class RGSpace(Space): (default: 0). """ + from nifty.field import Field if(not pl.isinteractive())and(not bool(kwargs.get("save",False))): about.warnings.cprint("WARNING: interactive mode off.") @@ -453,11 +453,11 @@ class RGSpace(Space): if(isinstance(other,tuple)): other = list(other) for ii in xrange(len(other)): - if(isinstance(other[ii],field)): + if(isinstance(other[ii],Field)): other[ii] = other[ii].power(**kwargs) else: other[ii] = self.enforce_power(other[ii],size=np.size(xaxes),kindex=xaxes) - elif(isinstance(other,field)): + elif(isinstance(other,Field)): other = [other.power(**kwargs)] else: other = [self.enforce_power(other,size=np.size(xaxes),kindex=xaxes)] @@ -623,6 +623,8 @@ class RGSpace(Space): Whether a scalar is extented to a constant array or not (default: True). """ + from nifty.field import Field + about.warnings.cflush( "WARNING: _enforce_values is deprecated function. Please use self.cast") if(isinstance(x, Field)): diff --git a/spaces/rg_space/rg_space_paradict.py b/nifty/spaces/rg_space/rg_space_paradict.py similarity index 100% rename from spaces/rg_space/rg_space_paradict.py rename to nifty/spaces/rg_space/rg_space_paradict.py diff --git a/spaces/space/__init__.py b/nifty/spaces/space/__init__.py similarity index 100% rename from spaces/space/__init__.py rename to nifty/spaces/space/__init__.py diff --git a/spaces/space/space.py b/nifty/spaces/space/space.py similarity index 100% rename from spaces/space/space.py rename to nifty/spaces/space/space.py diff --git a/spaces/space/space_paradict.py b/nifty/spaces/space/space_paradict.py similarity index 100% rename from spaces/space/space_paradict.py rename to nifty/spaces/space/space_paradict.py diff --git a/test/hdf5_init_test.hdf5 b/nifty/test/hdf5_init_test.hdf5 similarity index 100% rename from test/hdf5_init_test.hdf5 rename to nifty/test/hdf5_init_test.hdf5 diff --git a/test/hdf5_test_folder/hdf5_init_test.hdf5 b/nifty/test/hdf5_test_folder/hdf5_init_test.hdf5 similarity index 100% rename from test/hdf5_test_folder/hdf5_init_test.hdf5 rename to nifty/test/hdf5_test_folder/hdf5_init_test.hdf5 diff --git a/test/hdf5_test_folder/hdf5_init_test_2.hdf5 b/nifty/test/hdf5_test_folder/hdf5_init_test_2.hdf5 similarity index 100% rename from test/hdf5_test_folder/hdf5_init_test_2.hdf5 rename to nifty/test/hdf5_test_folder/hdf5_init_test_2.hdf5 diff --git a/test/test_nifty_field.py b/nifty/test/test_nifty_field.py similarity index 100% rename from test/test_nifty_field.py rename to nifty/test/test_nifty_field.py diff --git a/test/test_nifty_operators.py b/nifty/test/test_nifty_operators.py similarity index 100% rename from test/test_nifty_operators.py rename to nifty/test/test_nifty_operators.py diff --git a/test/test_nifty_spaces.py b/nifty/test/test_nifty_spaces.py similarity index 100% rename from test/test_nifty_spaces.py rename to nifty/test/test_nifty_spaces.py diff --git a/test/test_nifty_transforms.py b/nifty/test/test_nifty_transforms.py similarity index 100% rename from test/test_nifty_transforms.py rename to nifty/test/test_nifty_transforms.py diff --git a/test/test_nifty_utilities.py b/nifty/test/test_nifty_utilities.py similarity index 100% rename from test/test_nifty_utilities.py rename to nifty/test/test_nifty_utilities.py diff --git a/transformations/__init__.py b/nifty/transformations/__init__.py similarity index 100% rename from transformations/__init__.py rename to nifty/transformations/__init__.py diff --git a/transformations/gllmtransformation.py b/nifty/transformations/gllmtransformation.py similarity index 100% rename from transformations/gllmtransformation.py rename to nifty/transformations/gllmtransformation.py diff --git a/transformations/hplmtransformation.py b/nifty/transformations/hplmtransformation.py similarity index 100% rename from transformations/hplmtransformation.py rename to nifty/transformations/hplmtransformation.py diff --git a/transformations/lmgltransformation.py b/nifty/transformations/lmgltransformation.py similarity index 100% rename from transformations/lmgltransformation.py rename to nifty/transformations/lmgltransformation.py diff --git a/transformations/lmhptransformation.py b/nifty/transformations/lmhptransformation.py similarity index 100% rename from transformations/lmhptransformation.py rename to nifty/transformations/lmhptransformation.py diff --git a/transformations/rg_transforms.py b/nifty/transformations/rg_transforms.py similarity index 100% rename from transformations/rg_transforms.py rename to nifty/transformations/rg_transforms.py diff --git a/transformations/rgrgtransformation.py b/nifty/transformations/rgrgtransformation.py similarity index 100% rename from transformations/rgrgtransformation.py rename to nifty/transformations/rgrgtransformation.py diff --git a/transformations/transformation.py b/nifty/transformations/transformation.py similarity index 100% rename from transformations/transformation.py rename to nifty/transformations/transformation.py diff --git a/transformations/transformation_factory.py b/nifty/transformations/transformation_factory.py similarity index 96% rename from transformations/transformation_factory.py rename to nifty/transformations/transformation_factory.py index 5e96aa27..8d527592 100644 --- a/transformations/transformation_factory.py +++ b/nifty/transformations/transformation_factory.py @@ -1,5 +1,4 @@ -from nifty.rg import RGSpace -from nifty.lm import GLSpace, HPSpace, LMSpace +from nifty.spaces import RGSpace, GLSpace, HPSpace, LMSpace from rgrgtransformation import RGRGTransformation from gllmtransformation import GLLMTransformation diff --git a/version.py b/nifty/version.py similarity index 100% rename from version.py rename to nifty/version.py diff --git a/nifty_config b/nifty_config deleted file mode 100644 index 5595ad49..00000000 --- a/nifty_config +++ /dev/null @@ -1,9 +0,0 @@ -[DEFAULT] -use_libsharp = True -use_healpy = True -verbosity = 1 -fft_module = pyfftw -default_comm = COMM_WORLD -mpi_module = MPI -lm2gl = True - diff --git a/nifty_paradict.py b/nifty_paradict.py deleted file mode 100644 index d74fc34a..00000000 --- a/nifty_paradict.py +++ /dev/null @@ -1,221 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Thu Apr 2 21:29:30 2015 - -@author: steininger -""" - -import numpy as np -from nifty.config import about - - -class space_paradict(object): - - def __init__(self, **kwargs): - if not hasattr(self, 'parameters'): - self.parameters = {} - for key in kwargs: - self[key] = kwargs[key] - - def __iter__(self): - return self.parameters.__iter__() - - def __eq__(self, other): - return (isinstance(other, self.__class__) and - self.__dict__ == other.__dict__) - - def __ne__(self, other): - return not self.__eq__(other) - - def __repr__(self): - return self.parameters.__repr__() - - def __setitem__(self, key, arg): - raise NotImplementedError - - def __getitem__(self, key): - return self.parameters.__getitem__(key) - - def __hash__(self): - result_hash = 0 - for (key, item) in self.parameters.items(): - try: - temp_hash = hash(item) - except TypeError: - temp_hash = hash(tuple(item)) - result_hash ^= temp_hash ^ int(hash(key)/131) - return result_hash - - -class rg_space_paradict(space_paradict): - - def __init__(self, shape, zerocenter, distances, harmonic): - if not hasattr(self, 'parameters'): - self.parameters = {} - self.parameters.__setitem__('shape', shape) - self.parameters.__setitem__('harmonic', harmonic) - space_paradict.__init__( - self, zerocenter=zerocenter, distances=distances) - - def __setitem__(self, key, arg): - if key not in ['shape', 'zerocenter', 'distances']: - raise ValueError(about._errors.cstring( - "ERROR: Unsupported RGSpace parameter:" + key)) - - if key == 'shape': - temp = np.empty(len(self['shape']), dtype=np.int) - temp[:] = arg - temp = tuple(temp) - elif key == 'zerocenter': - temp = np.empty(len(self['shape']), dtype=bool) - temp[:] = arg - temp = tuple(temp) - elif key == 'distances': - if arg is None: - if self['harmonic']: - temp = np.ones_like(self['shape'], dtype=np.float) - else: - temp = 1 / np.array(self['shape'], dtype=np.float) - else: - temp = np.empty(len(self['shape']), dtype=np.float) - temp[:] = arg - temp = tuple(temp) - elif key == 'harmonic': - temp = bool(arg) - - self.parameters.__setitem__(key, temp) - - -class lm_space_paradict(space_paradict): - - def __init__(self, lmax, mmax): - space_paradict.__init__(self, lmax=lmax) - if mmax is None: - mmax = -1 - self['mmax'] = mmax - - def __setitem__(self, key, arg): - if key not in ['lmax', 'mmax']: - raise ValueError(about._errors.cstring( - "ERROR: Unsupported LMSpace parameter: " + key)) - - if key == 'lmax': - temp = np.int(arg) - if temp < 1: - raise ValueError(about._errors.cstring( - "ERROR: lmax: nonpositive number.")) - # exception lmax == 2 (nside == 1) - if (temp % 2 == 0) and (temp > 2): - about.warnings.cprint( - "WARNING: unrecommended parameter (lmax <> 2*n+1).") - try: - if temp < self['mmax']: - about.warnings.cprint( - "WARNING: mmax parameter set to lmax.") - self['mmax'] = temp - if (temp != self['mmax']): - about.warnings.cprint( - "WARNING: unrecommended parameter set (mmax <> lmax).") - except: - pass - elif key == 'mmax': - temp = int(arg) - if (temp < 1) or(temp > self['lmax']): - about.warnings.cprint( - "WARNING: mmax parameter set to default.") - temp = self['lmax'] - if(temp != self['lmax']): - about.warnings.cprint( - "WARNING: unrecommended parameter set (mmax <> lmax).") - - self.parameters.__setitem__(key, temp) - - -class gl_space_paradict(space_paradict): - - def __init__(self, nlat, nlon): - space_paradict.__init__(self, nlat=nlat) - if nlon is None: - nlon = -1 - self['nlon'] = nlon - - def __setitem__(self, key, arg): - if key not in ['nlat', 'nlon']: - raise ValueError(about._errors.cstring( - "ERROR: Unsupported GLSpace parameter: " + key)) - - if key == 'nlat': - temp = int(arg) - if(temp < 1): - raise ValueError(about._errors.cstring( - "ERROR: nlat: nonpositive number.")) - if (temp % 2 != 0): - raise ValueError(about._errors.cstring( - "ERROR: invalid parameter (nlat <> 2n).")) - try: - if temp < self['mmax']: - about.warnings.cprint( - "WARNING: mmax parameter set to lmax.") - self['mmax'] = temp - if (temp != self['mmax']): - about.warnings.cprint( - "WARNING: unrecommended parameter set (mmax <> lmax).") - except: - pass - elif key == 'nlon': - temp = int(arg) - if (temp < 1): - about.warnings.cprint( - "WARNING: nlon parameter set to default.") - temp = 2 * self['nlat'] - 1 - if(temp != 2 * self['nlat'] - 1): - about.warnings.cprint( - "WARNING: unrecommended parameter set (nlon <> 2*nlat-1).") - self.parameters.__setitem__(key, temp) - - -class hp_space_paradict(space_paradict): - - def __init__(self, nside): - space_paradict.__init__(self, nside=nside) - - def __setitem__(self, key, arg): - if key not in ['nside']: - raise ValueError(about._errors.cstring( - "ERROR: Unsupported hp_space parameter")) - - temp = int(arg) - # if(not hp.isnsideok(nside)): - if ((temp & (temp - 1)) != 0) or (temp < 2): - raise ValueError(about._errors.cstring( - "ERROR: invalid parameter ( nside <> 2**n ).")) - self.parameters.__setitem__(key, temp) - - -class power_space_paradict(space_paradict): - def __init__(self, pindex, kindex, rho, config, harmonic_domain): - space_paradict.__init__(self, - pindex=pindex, - kindex=kindex, - rho=rho, - config=config, - harmonic_domain=harmonic_domain) - - def __setitem__(self, key, arg): - if key not in ['pindex', 'kindex', 'rho', 'config', 'harmonic_domain']: - raise ValueError(about._errors.cstring( - "ERROR: Unsupported PowerSpace parameter: " + key)) - - if key == 'harmonic_domain': - if not arg.harmonic: - raise ValueError(about._errors.cstring( - "ERROR: harmonic_domain must be harmonic.")) - temp = arg - else: - temp = arg - - self.parameters.__setitem__(key, temp) - - def __hash__(self): - return (hash(frozenset(self.parameters['config'].items())) ^ - (hash(self.parameters['harmonic_domain'])/131)) diff --git a/nifty_power_indices.py b/nifty_power_indices.py deleted file mode 100644 index 7d0fe67d..00000000 --- a/nifty_power_indices.py +++ /dev/null @@ -1,736 +0,0 @@ -# -*- coding: utf-8 -*- - -import numpy as np -from d2o import distributed_data_object,\ - STRATEGIES as DISTRIBUTION_STRATEGIES - -from nifty.config import about,\ - nifty_configuration as gc,\ - dependency_injector as gdi - -MPI = gdi[gc['mpi_module']] -hp = gdi.get('healpy') - - -class power_indices(object): - def __init__(self, datamodel, allowed_distribution_strategies, comm, - log=False, nbin=None, binbounds=None): - """ - Returns an instance of the power_indices class. Given the shape and - the density of a underlying rectangular grid it provides the user - with the pindex, kindex, rho and pundex. The indices are bined - according to the supplied parameter scheme. If wanted, computed - results are stored for future reuse. - - Parameters - ---------- - shape : tuple, list, ndarray - Array-like object which specifies the shape of the underlying - rectangular grid - dgrid : tuple, list, ndarray - Array-like object which specifies the step-width of the - underlying grid - zerocentered : boolean, tuple/list/ndarray of boolean *optional* - Specifies which dimensions are zerocentered. (default:False) - log : bool *optional* - Flag specifying if the binning of the default indices is - performed on logarithmic scale. - nbin : integer *optional* - Number of used bins for the binning of the default indices. - binbounds : {list, array} - Array-like inner boundaries of the used bins of the default - indices. - """ - if comm is None: - self.comm = getattr(gdi[gc['mpi_module']], gc['default_comm']) - else: - self.comm = comm - - self.datamodel = datamodel - self.allowed_distribution_strategies = allowed_distribution_strategies - - # Compute the global kdict - self.kdict = self.compute_kdict() - # Initialize the dictonary which stores all individual index-dicts - self.global_dict = {} - # Set self.default_parameters - self.set_default(config_dict={'log': log, - 'nbin': nbin, - 'binbounds': binbounds}) - - # Redirect the direct calls approaching a power_index instance to the - # default_indices dict - @property - def default_indices(self): - return self.get_index_dict(**self.default_parameters) - - def __getitem__(self, x): - return self.default_indices.get(x) - - def __contains__(self, x): - return self.default_indices.__contains__(x) - - def __iter__(self): - return self.default_indices.__iter__() - - def __getattr__(self, x): - return self.default_indices.__getattribute__(x) - - def set_default(self, **kwargs): - """ - Sets the index-set which is specified by the parameters as the - default for the power_index instance. - - Parameters - ---------- - log : bool - Flag specifying if the binning is performed on logarithmic - scale. - nbin : integer - Number of used bins. - binbounds : {list, array} - Array-like inner boundaries of the used bins. - - Returns - ------- - None - """ - parsed_kwargs = self._cast_config(**kwargs) - self.default_parameters = parsed_kwargs - - def _cast_config(self, **kwargs): - """ - internal helper function which casts the various combinations of - possible parameters into a properly defaulted dictionary - """ - temp_config_dict = kwargs.get('config_dict', None) - if temp_config_dict is not None: - return self._cast_config_helper(**temp_config_dict) - else: - defaults = self.default_parameters - temp_log = kwargs.get("log", defaults['log']) - temp_nbin = kwargs.get("nbin", defaults['nbin']) - temp_binbounds = kwargs.get("binbounds", defaults['binbounds']) - - return self._cast_config_helper(log=temp_log, - nbin=temp_nbin, - binbounds=temp_binbounds) - - def _cast_config_helper(self, log, nbin, binbounds): - """ - internal helper function which sets the defaults for the - _cast_config function - """ - - try: - temp_log = bool(log) - except(TypeError): - temp_log = False - - try: - temp_nbin = int(nbin) - except(TypeError): - temp_nbin = None - - try: - temp_binbounds = tuple(np.array(binbounds)) - except(TypeError): - temp_binbounds = None - - temp_dict = {"log": temp_log, - "nbin": temp_nbin, - "binbounds": temp_binbounds} - return temp_dict - - def compute_kdict(self): - raise NotImplementedError( - about._errors.cstring( - "ERROR: No generic compute_kdict method implemented.")) - - def get_index_dict(self, **kwargs): - """ - Returns a dictionary containing the pindex, kindex, rho and pundex - binned according to the supplied parameter scheme and a - configuration dict containing this scheme. - - Parameters - ---------- - store : bool - Flag specifying if the calculated index dictionary should be - stored in the global_dict for future use. - log : bool - Flag specifying if the binning is performed on logarithmic - scale. - nbin : integer - Number of used bins. - binbounds : {list, array} - Array-like inner boundaries of the used bins. - - Returns - ------- - index_dict : dict - Contains the keys: 'config', 'pindex', 'kindex', 'rho' and - 'pundex' - """ - # Cast the input arguments - temp_config_dict = self._cast_config(**kwargs) - # Compute a hashable identifier from the config which will be used - # as dict key - temp_key = self._freeze_config(temp_config_dict) - # Check if the result should be stored for future use. - storeQ = kwargs.get("store", True) - # Try to find the requested index dict in the global_dict - try: - return self.global_dict[temp_key] - except(KeyError): - # If it is not found, calculate it. - temp_index_dict = self._compute_index_dict(temp_config_dict) - # Store it, if required - if storeQ: - self.global_dict[temp_key] = temp_index_dict - # Important: If the result is stored, return a reference to - # the dictionary entry, not anly a plain copy. Otherwise, - # set_default breaks! - return self.global_dict[temp_key] - else: - # Return the plain result. - return temp_index_dict - - def _freeze_config(self, config_dict): - """ - a helper function which forms a hashable identifying object from - a config dictionary which can be used as key of a dict - """ - return frozenset(config_dict.items()) - - def _compute_index_dict(self, config_dict): - """ - Internal helper function which takes a config_dict, asks for the - pindex/kindex/rho/pundex set, and bins them according to the config - """ - # if no binning is requested, compute the indices, build the dict, - # and return it straight. - if not config_dict["log"] and config_dict["nbin"] is None and \ - config_dict["binbounds"] is None: - (temp_pindex, temp_kindex, temp_rho, temp_pundex) =\ - self._compute_indices(self.kdict) - temp_kdict = self.kdict - - # if binning is required, make a recursive call to get the unbinned - # indices, bin them, compute the pundex and then return everything. - else: - # Get the unbinned indices - temp_unbinned_indices = self.get_index_dict(nbin=None, - binbounds=None, - log=False, - store=False) - # Bin them - (temp_pindex, temp_kindex, temp_rho, temp_pundex) = \ - self._bin_power_indices( - temp_unbinned_indices, **config_dict) - # Make a binned version of kdict - temp_kdict = self._compute_kdict_from_pindex_kindex(temp_pindex, - temp_kindex) - - temp_index_dict = {"config": config_dict, - "pindex": temp_pindex, - "kindex": temp_kindex, - "rho": temp_rho, - "pundex": temp_pundex, - "kdict": temp_kdict} - return temp_index_dict - - def _compute_kdict_from_pindex_kindex(self, pindex, kindex): - if isinstance(pindex, distributed_data_object): - tempindex = pindex.copy(dtype=kindex.dtype) - result = tempindex.apply_scalar_function( - lambda x: kindex[x.astype(np.dtype('int'))]) - else: - result = kindex[pindex].astype(dtype=kindex.dtype) - return result - - def _compute_indices(self, nkdict): - if self.datamodel in ['np']: - return self._compute_indices_np(nkdict) - elif self.datamodel in self.allowed_distribution_strategies: - return self._compute_indices_d2o(nkdict) - else: - raise ValueError(about._errors.cstring( - 'ERROR: Datamodel is not supported.')) - - def _compute_indices_d2o(self, nkdict): - """ - Internal helper function which computes pindex, kindex, rho and pundex - from a given nkdict - """ - raise NotImplementedError( - about._errors.cstring( - "ERROR: No generic _compute_indices_d2o method implemented.")) - - def _compute_pundex_d2o(self, global_pindex, global_kindex): - """ - Internal helper function which computes the pundex array from a - pindex and a kindex array. This function is separated from the - _compute_indices function as it is needed in _bin_power_indices, - too. - """ - if self.datamodel in DISTRIBUTION_STRATEGIES['slicing']: - ########## - # pundex # - ########## - # Prepare the local data - local_pindex = global_pindex.get_local_data() - # Compute the local pundices for the local pindices - (temp_uniqued_pindex, local_temp_pundex) = np.unique( - local_pindex, - return_index=True) - # Shift the local pundices by the nodes' local_dim_offset - local_temp_pundex += global_pindex.distributor.local_dim_offset - - # Prepare the pundex arrays used for the Allreduce operation - # pundex has the same length as the kindex array - local_pundex = np.zeros(shape=global_kindex.shape, dtype=np.int) - # Set the default value higher than the maximal possible pundex - # value so that MPI.MIN can sort out the default - local_pundex += reduce(lambda x, y: x * y, global_pindex.shape) + 1 - # Set the default value higher than the length - global_pundex = np.empty_like(local_pundex) - # Store the individual pundices in the local_pundex array - local_pundex[temp_uniqued_pindex] = local_temp_pundex - # Use Allreduce to find the first occurences/smallest pundices - self.comm.Allreduce(local_pundex, global_pundex, op=MPI.MIN) - return global_pundex - - elif self.datamodel in DISTRIBUTION_STRATEGIES['not']: - ########## - # pundex # - ########## - pundex = np.unique(global_pindex.get_local_data(), - return_index=True)[1] - return pundex - else: - raise NotImplementedError(about._errors.cstring( - "ERROR: _compute_pundex_d2o for given datamodel not " + - "implemented.")) - - def _compute_indices_np(self, nkdict): - """ - Internal helper function which computes pindex, kindex, rho and pundex - from a given nkdict - """ - raise NotImplementedError( - about._errors.cstring( - "ERROR: No generic _compute_indices_np method implemented.")) - - def _compute_pundex_np(self, pindex, kindex): - """ - Internal helper function which computes the pundex array from a - pindex and a kindex array. This function is separated from the - _compute_indices function as it is needed in _bin_power_indices, - too. - """ - ########## - # pundex # - ########## - pundex = np.unique(pindex, return_index=True)[1] - return pundex - - def _bin_power_indices(self, index_dict, **kwargs): - """ - Returns the binned power indices associated with the Fourier grid. - - Parameters - ---------- - pindex : distributed_data_object - Index of the Fourier grid points in a distributed_data_object. - kindex : ndarray - Array of all k-vector lengths. - rho : ndarray - Degeneracy factor of the individual k-vectors. - log : bool - Flag specifying if the binning is performed on logarithmic - scale. - nbin : integer - Number of used bins. - binbounds : {list, array} - Array-like inner boundaries of the used bins. - - Returns - ------- - pindex : distributed_data_object - kindex, rho, pundex : ndarrays - The (re)binned power indices. - - """ - # Cast the given config - temp_config_dict = self._cast_config(**kwargs) - log = temp_config_dict['log'] - nbin = temp_config_dict['nbin'] - binbounds = temp_config_dict['binbounds'] - - # Extract the necessary indices from the supplied index dict - pindex = index_dict["pindex"] - kindex = index_dict["kindex"] - rho = index_dict["rho"] - - # boundaries - if(binbounds is not None): - binbounds = np.sort(binbounds) - # equal binning - else: - if(log is None): - log = False - if(log): - k = np.r_[0, np.log(kindex[1:])] - else: - k = kindex - dk = np.max(k[2:] - k[1:-1]) # minimal dk - if(nbin is None): - nbin = int((k[-1] - 0.5 * (k[2] + k[1])) / - dk - 0.5) # maximal nbin - else: - nbin = min(int(nbin), int( - (k[-1] - 0.5 * (k[2] + k[1])) / dk + 2.5)) - dk = (k[-1] - 0.5 * (k[2] + k[1])) / (nbin - 2.5) - binbounds = np.r_[0.5 * (3 * k[1] - k[2]), - 0.5 * (k[1] + k[2]) + dk * np.arange(nbin - 2)] - if(log): - binbounds = np.exp(binbounds) - # reordering - reorder = np.searchsorted(binbounds, kindex) - rho_ = np.zeros(len(binbounds) + 1, dtype=rho.dtype) - kindex_ = np.empty(len(binbounds) + 1, dtype=kindex.dtype) - for ii in range(len(reorder)): - if(rho_[reorder[ii]] == 0): - kindex_[reorder[ii]] = kindex[ii] - rho_[reorder[ii]] += rho[ii] - else: - kindex_[reorder[ii]] = ((kindex_[reorder[ii]] * - rho_[reorder[ii]] + - kindex[ii] * rho[ii]) / - (rho_[reorder[ii]] + rho[ii])) - rho_[reorder[ii]] += rho[ii] - - if self.datamodel == 'np': - pindex_ = reorder[pindex] - pundex_ = self._compute_pundex_np(pindex_, kindex_) - elif self.datamodel in self.allowed_distribution_strategies: - pindex_ = pindex.copy_empty() - pindex_.set_local_data(reorder[pindex.get_local_data()]) - pundex_ = self._compute_pundex_d2o(pindex_, kindex_) - else: - raise ValueError(about._errors.cstring( - 'ERROR: Datamodel is not supported.')) - - return pindex_, kindex_, rho_, pundex_ - - -class rg_power_indices(power_indices): - - def __init__(self, shape, dgrid, allowed_distribution_strategies, - datamodel='not', zerocentered=False, log=False, nbin=None, - binbounds=None, comm=None): - """ - Returns an instance of the power_indices class. Given the shape and - the density of a underlying rectangular grid it provides the user - with the pindex, kindex, rho and pundex. The indices are bined - according to the supplied parameter scheme. If wanted, computed - results are stored for future reuse. - - Parameters - ---------- - shape : tuple, list, ndarray - Array-like object which specifies the shape of the underlying - rectangular grid - dgrid : tuple, list, ndarray - Array-like object which specifies the step-width of the - underlying grid - zerocentered : boolean, tuple/list/ndarray of boolean *optional* - Specifies which dimensions are zerocentered. (default:False) - log : bool *optional* - Flag specifying if the binning of the default indices is - performed on logarithmic scale. - nbin : integer *optional* - Number of used bins for the binning of the default indices. - binbounds : {list, array} - Array-like inner boundaries of the used bins of the default - indices. - """ - # Basic inits and consistency checks - self.shape = np.array(shape, dtype=int) - self.dgrid = np.abs(np.array(dgrid)) - if self.shape.shape != self.dgrid.shape: - raise ValueError(about._errors.cstring("ERROR: The supplied shape\ - and dgrid have not the same dimensionality")) - self.zerocentered = self._cast_zerocentered(zerocentered) - - super(rg_power_indices, self).__init__( - datamodel=datamodel, - allowed_distribution_strategies=allowed_distribution_strategies, - comm=comm, - log=log, - nbin=nbin, - binbounds=binbounds) - - def _cast_zerocentered(self, zerocentered=False): - """ - internal helper function which brings the zerocentered input in - the form of a boolean-tuple - """ - zc = np.array(zerocentered).astype(bool) - if zc.shape == self.shape.shape: - return tuple(zc) - else: - temp = np.empty(shape=self.shape.shape, dtype=bool) - temp[:] = zc - return tuple(temp) - - def compute_kdict(self): - """ - Calculates an n-dimensional array with its entries being the - lengths of the k-vectors from the zero point of the grid. - - Parameters - ---------- - None : All information is taken from the parent object. - - Returns - ------- - nkdict : distributed_data_object - """ - shape = self.shape - if self.datamodel == 'np': - slice_of_first_dimension = slice(0, shape[0]) - nkdict = self._compute_kdict_helper(slice_of_first_dimension) - - elif self.datamodel in self.allowed_distribution_strategies: - # prepare the distributed_data_object - nkdict = distributed_data_object( - global_shape=shape, - dtype=np.float128, - distribution_strategy=self.datamodel, - comm=self.comm) - if self.datamodel in DISTRIBUTION_STRATEGIES['slicing']: - # get the node's individual slice of the first dimension - slice_of_first_dimension = slice( - *nkdict.distributor.local_slice[0:2]) - elif self.datamodel in DISTRIBUTION_STRATEGIES['not']: - slice_of_first_dimension = slice(0, shape[0]) - else: - raise ValueError(about._errors.cstring( - "ERROR: Unsupported distribution strategy")) - dists = self._compute_kdict_helper(slice_of_first_dimension) - nkdict.set_local_data(dists) - - else: - raise ValueError(about._errors.cstring( - - "ERROR: Unsupported datamodel")) - return nkdict - - def _compute_kdict_helper(self, slice_of_first_dimension): - dk = self.dgrid - shape = self.shape - - inds = [] - for a in shape: - inds += [slice(0, a)] - - cords = np.ogrid[inds] - - dists = ((np.float128(0) + cords[0] - shape[0] // 2) * dk[0])**2 - # apply zerocenteredQ shift - if self.zerocentered[0] == False: - dists = np.fft.fftshift(dists) - # only save the individual slice - dists = dists[slice_of_first_dimension] - for ii in range(1, len(shape)): - temp = ((cords[ii] - shape[ii] // 2) * dk[ii])**2 - if self.zerocentered[ii] == False: - temp = np.fft.fftshift(temp) - dists = dists + temp - dists = np.sqrt(dists) - return dists - - def _compute_indices_d2o(self, nkdict): - """ - Internal helper function which computes pindex, kindex, rho and pundex - from a given nkdict - """ - ########## - # kindex # - ########## - global_kindex = nkdict.unique() - - ########## - # pindex # - ########## - # compute the local pindex slice on basis of the local nkdict data - local_pindex = np.searchsorted(global_kindex, nkdict.get_local_data()) - # prepare the distributed_data_object - global_pindex = distributed_data_object( - global_shape=nkdict.shape, - dtype=local_pindex.dtype, - distribution_strategy=self.datamodel, - comm=self.comm) - # store the local pindex data in the global_pindex d2o - global_pindex.set_local_data(local_pindex) - - ####### - # rho # - ####### - global_rho = global_pindex.bincount() - - ########## - # pundex # - ########## - global_pundex = self._compute_pundex_d2o(global_pindex, - global_kindex) - - return global_pindex, global_kindex, global_rho, global_pundex - - def _compute_indices_np(self, nkdict): - """ - Internal helper function which computes pindex, kindex, rho and pundex - from a given nkdict - """ - ########## - # kindex # - ########## - kindex = np.unique(nkdict) - - ########## - # pindex # - ########## - pindex = np.searchsorted(kindex, nkdict) - - ####### - # rho # - ####### - rho = np.bincount(pindex.flatten()) - - ########## - # pundex # - ########## - pundex = self._compute_pundex_np(pindex, kindex) - - return pindex, kindex, rho, pundex - - -class lm_power_indices(power_indices): - - def __init__(self, lmax, dim, - allowed_distribution_strategies, datamodel='not', - zerocentered=False, log=False, nbin=None, - binbounds=None, comm=None): - """ - Returns an instance of the power_indices class. Given the shape and - the density of a underlying rectangular grid it provides the user - with the pindex, kindex, rho and pundex. The indices are bined - according to the supplied parameter scheme. If wanted, computed - results are stored for future reuse. - - Parameters - ---------- - shape : tuple, list, ndarray - Array-like object which specifies the shape of the underlying - rectangular grid - dgrid : tuple, list, ndarray - Array-like object which specifies the step-width of the - underlying grid - zerocentered : boolean, tuple/list/ndarray of boolean *optional* - Specifies which dimensions are zerocentered. (default:False) - log : bool *optional* - Flag specifying if the binning of the default indices is - performed on logarithmic scale. - nbin : integer *optional* - Number of used bins for the binning of the default indices. - binbounds : {list, array} - Array-like inner boundaries of the used bins of the default - indices. - """ - # Basic inits and consistency checks - self.lmax = np.uint(lmax) - self.dim = np.uint(dim) - super(lm_power_indices, self).__init__( - datamodel=datamodel, - allowed_distribution_strategies=allowed_distribution_strategies, - comm=comm, - log=log, - nbin=nbin, - binbounds=binbounds) - - def compute_kdict(self): - """ - Calculates an n-dimensional array with its entries being the - lengths of the k-vectors from the zero point of the grid. - - Parameters - ---------- - None : All information is taken from the parent object. - - Returns - ------- - nkdict : distributed_data_object - """ - - if self.datamodel != 'not': - about.warnings.cprint( - "WARNING: full kdict is temporarily stored on every node " + - "altough disribution strategy != 'not'!") - - if self.datamodel in self.allowed_distribution_strategies: - if 'healpy' in gdi: - nkdict = hp.Alm.getlm(self.lmax, i=None)[0] - else: - nkdict = self._getlm()[0] - nkdict = distributed_data_object( - nkdict, - distribution_strategy=self.datamodel, - comm=self.comm) - else: - raise ValueError(about._errors.cstring( - "ERROR: Unsupported datamodel")) - return nkdict - - def _getlm(self): # > compute all (l,m) - index = np.arange(self.dim) - n = 2 * self.lmax + 1 - m = np.ceil((n - np.sqrt(n**2 - 8 * (index - self.lmax))) / 2 - ).astype(np.int) - l = index - self.lmax * m + m * (m - 1) // 2 - return l, m - - def _compute_indices(self, nkdict): - if self.datamodel in self.allowed_distribution_strategies: - return self._compute_indices_d2o(nkdict) - else: - raise ValueError(about._errors.cstring( - 'ERROR: Datamodel is not supported.')) - - def _compute_indices_d2o(self, nkdict): - """ - Internal helper function which computes pindex, kindex, rho and pundex - from a given nkdict - """ - ########## - # kindex # - ########## - kindex = np.arange(self.lmax + 1, dtype=np.float) - - ########## - # pindex # - ########## - pindex = nkdict.copy(dtype=np.int) - - ####### - # rho # - ####### - rho = (2 * kindex + 1).astype(np.int) - - ########## - # pundex # - ########## - pundex = self._compute_pundex_d2o(pindex, kindex) - - return pindex, kindex, rho, pundex diff --git a/pickling.py b/pickling.py deleted file mode 100644 index d8974660..00000000 --- a/pickling.py +++ /dev/null @@ -1,54 +0,0 @@ -## NIFTY (Numerical Information Field Theory) has been developed at the -## Max-Planck-Institute for Astrophysics. -## -## Copyright (C) 2013 Max-Planck-Society -## -## Author: Marco Selig -## Project homepage: -## -## This program is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -## See the GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . - -import copy_reg as cr -from types import MethodType as mt - - -##----------------------------------------------------------------------------- - -def _pickle_method(method): - fct_name = method.im_func.__name__ - obj = method.im_self - cl = method.im_class - ## handle mangled function name - if(fct_name.startswith("__"))and(not fct_name.endswith("__")): - cl_name = cl.__name__.lstrip("_") - fct_name = "_" + cl_name + fct_name - return _unpickle_method, (fct_name, obj, cl) - -##----------------------------------------------------------------------------- - -def _unpickle_method(fct_name, obj, cl): - for oo in cl.__mro__: - try: - fct = oo.__dict__[fct_name] - except(KeyError): - pass - else: - break - return fct.__get__(obj, cl) - -##----------------------------------------------------------------------------- - -## enable instance methods pickling -cr.pickle(mt, _pickle_method, _unpickle_method) - diff --git a/setup.py b/setup.py index 7547fef6..bc06c13c 100644 --- a/setup.py +++ b/setup.py @@ -22,25 +22,21 @@ from setuptools import setup, find_packages import os -exec(open('version.py').read()) +exec(open('nifty/version.py').read()) setup(name="ift_nifty", version=__version__, - author="Marco Selig", - author_email="mselig@mpa-garching.mpg.de", - maintainer="Theo Steininger", - maintainer_email="theos@mpa-garching.mpg.de", + author="Theo Steininger", + author_email="theos@mpa-garching.mpg.de", description="Numerical Information Field Theory", url="http://www.mpa-garching.mpg.de/ift/nifty/", packages=find_packages(), - package_dir={"nifty": ""}, + package_dir={"nifty": "nifty"}, zip_safe=False, dependency_links=[ 'git+https://gitlab.mpcdf.mpg.de/ift/keepers.git#egg=keepers', 'git+https://gitlab.mpcdf.mpg.de/ift/d2o.git#egg=d2o'], install_requires=['keepers', 'd2o'], - data_files=[(os.path.expanduser('~') + "/.nifty", - ['nifty_config', 'd2o_config'])], package_data={'nifty.demos': ['demo_faraday_map.npy'], }, license="GPLv3", diff --git a/spaces/lm_space/__init__.py b/spaces/lm_space/__init__.py deleted file mode 100644 index 5aed7b30..00000000 --- a/spaces/lm_space/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# -*- coding: utf-8 -*- - - -from lm_space import LMSpace -from lm_space_paradict import LMSpaceParadict -from nifty_power_conversion_lm import power_backward_conversion_lm,\ - power_forward_conversion_lm - diff --git a/spaces/lm_space/nifty_power_conversion_lm.py b/spaces/lm_space/nifty_power_conversion_lm.py deleted file mode 100644 index cd006192..00000000 --- a/spaces/lm_space/nifty_power_conversion_lm.py +++ /dev/null @@ -1,153 +0,0 @@ -## NIFTY (Numerical Information Field Theory) has been developed at the -## Max-Planck-Institute for Astrophysics. -## -## Copyright (C) 2014 Max-Planck-Society -## -## Author: Maksim Greiner, Marco Selig -## Project homepage: -## -## This program is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -## See the GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . - -#from nifty import * -import numpy as np -from numpy import pi -from nifty.config import about -from nifty.field import Field -from nifty.nifty_simple_math import sqrt, exp, log - - -def power_backward_conversion_lm(k_space, p, mean=None): - """ - This function is designed to convert a theoretical/statistical power - spectrum of a log-normal field to the theoretical power spectrum of - the underlying Gaussian field. - The function only works for power spectra defined for lm_spaces - - Parameters - ---------- - k_space : nifty.rg_space, - a regular grid space with the attribute `Fourier = True` - p : np.array, - the power spectrum of the log-normal field. - Needs to have the same number of entries as - `k_space.get_power_indices()[0]` - mean : float, *optional* - specifies the mean of the log-normal field. If `mean` is not - specified the function will use the monopole of the power spectrum. - If it is specified the function will NOT use the monopole of the - spectrum. (default: None) - WARNING: a mean that is too low can violate positive definiteness - of the log-normal field. In this case the function produces an - error. - - Returns - ------- - mean : float, - the recovered mean of the underlying Gaussian distribution. - p1 : np.array, - the power spectrum of the underlying Gaussian field, where the - monopole has been set to zero. Eventual monopole power has been - shifted to the mean. - - References - ---------- - .. [#] M. Greiner and T.A. Ensslin, "Log-transforming the matter power spectrum"; - `arXiv:1312.1354 `_ - """ - - p = np.copy(p) - if(mean is not None): - p[0] = 4*pi*mean**2 - - klen = k_space.get_power_indices()[0] - C_0_Omega = Field(k_space,val=0) - C_0_Omega.val[:len(klen)] = p*sqrt(2*klen+1)/sqrt(4*pi) - C_0_Omega = C_0_Omega.transform() - - if(np.any(C_0_Omega.val<0.)): - raise ValueError(about._errors.cstring("ERROR: spectrum or mean incompatible with positive definiteness.\n Try increasing the mean.")) - return None - - lC = log(C_0_Omega) - - Z = lC.transform() - - spec = Z.val[:len(klen)] - - mean = (spec[0]-0.5*sqrt(4*pi)*log((p*(2*klen+1)/(4*pi)).sum()))/sqrt(4*pi) - - spec[0] = 0. - - spec = spec*sqrt(4*pi)/sqrt(2*klen+1) - - spec = np.real(spec) - - if(np.any(spec<0.)): - spec = spec*(spec>0.) - about.warnings.cprint("WARNING: negative modes set to zero.") - - return mean.real,spec - - -def power_forward_conversion_lm(k_space,p,mean=0): - """ - This function is designed to convert a theoretical/statistical power - spectrum of a Gaussian field to the theoretical power spectrum of - the exponentiated field. - The function only works for power spectra defined for lm_spaces - - Parameters - ---------- - k_space : nifty.rg_space, - a regular grid space with the attribute `Fourier = True` - p : np.array, - the power spectrum of the Gaussian field. - Needs to have the same number of entries as - `k_space.get_power_indices()[0]` - m : float, *optional* - specifies the mean of the Gaussian field (default: 0). - - Returns - ------- - p1 : np.array, - the power spectrum of the exponentiated Gaussian field. - - References - ---------- - .. [#] M. Greiner and T.A. Ensslin, "Log-transforming the matter power spectrum"; - `arXiv:1312.1354 `_ - """ - m = mean - klen = k_space.get_power_indices()[0] - C_0_Omega = Field(k_space,val=0) - C_0_Omega.val[:len(klen)] = p*sqrt(2*klen+1)/sqrt(4*pi) - C_0_Omega = C_0_Omega.transform() - - C_0_0 = (p*(2*klen+1)/(4*pi)).sum() - - exC = exp(C_0_Omega+C_0_0+2*m) - - Z = exC.transform() - - spec = Z.val[:len(klen)] - - spec = spec*sqrt(4*pi)/sqrt(2*klen+1) - - spec = np.real(spec) - - if(np.any(spec<0.)): - spec = spec*(spec>0.) - about.warnings.cprint("WARNING: negative modes set to zero.") - - return spec \ No newline at end of file -- GitLab