nifty_default_config.py 2.41 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# -*- coding: utf-8 -*-

import os

from nifty_dependency_injector import dependency_injector
from nifty_configuration import variable,\
                                configuration

global_dependency_injector = dependency_injector(
                                   ['h5py',
                                    ('mpi4py.MPI', 'MPI'),
                                    ('nifty.dummys.MPI_dummy', 'MPI_dummy'),
                                    'pyfftw',
                                    'gfft',
                                    ('nifty.dummys.gfft_dummy', 'gfft_dummy'),
                                    'healpy',
                                    'libsharp_wrapper_gl'])

19

20
21
22
23
24
25
26
variable_fft_module = variable('fft_module',
                               ['pyfftw', 'gfft', 'gfft_fallback'],
                               lambda z: z in global_dependency_injector)

variable_lm2gl = variable('lm2gl',
                          [True, False],
                          lambda z: z is True or z is False,
27
                          genus = 'boolean')
28
29
30
31

variable_verbosity = variable('verbosity',
                              [1],
                              lambda z: z == abs(int(z)),
32
                              genus = 'int')
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

variable_mpi_module = variable('mpi_module',
                               ['MPI', 'MPI_dummy'],
                               lambda z: z in global_dependency_injector)

variable_default_distribution_strategy = variable(
                            'default_distribution_strategy',
                            ['fftw', 'equal', 'not'],
                            lambda z: (('pyfftw' in global_dependency_injector)
                                       if (z == 'pyfftw') else True)
                                                  )

global_configuration = configuration(
                     [variable_fft_module,
                      variable_lm2gl,
                      variable_verbosity,
                      variable_mpi_module,
                      variable_default_distribution_strategy
                      ],
                     path=os.path.expanduser('~') + "/.nifty/global_config")
53
54
55
56
57
58
59
60
61


variable_default_comm = variable(
                     'default_comm',
                     ['COMM_WORLD'],
                     lambda z: hasattr(global_dependency_injector[
                                       global_configuration['mpi_module']], z))

global_configuration.register(variable_default_comm)
62
63