nifty_default_config.py 3.25 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
variable_fft_module = variable('fft_module',
                               ['pyfftw', 'gfft', 'gfft_fallback'],
                               lambda z: z in global_dependency_injector)

variable_lm2gl = variable('lm2gl',
                          [True, False],
Ultima's avatar
Ultima committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
                          lambda z: isinstance(z, bool),
                          genus='boolean')

variable_use_healpy = variable(
                          'use_healpy',
                          [True, False],
                          lambda z: (('healpy' in global_dependency_injector)
                                     if z else True) and isinstance(z, bool),
                          genus='boolean')

variable_use_libsharp = variable('use_libsharp',
                                 [True, False],
                                 lambda z: (('libsharp_wrapper_gl' in
                                             global_dependency_injector)
                                            if z else True) and
                                            isinstance(z, bool),
                                 genus='boolean')
43
44
45
46

variable_verbosity = variable('verbosity',
                              [1],
                              lambda z: z == abs(int(z)),
Ultima's avatar
Ultima committed
47
                              genus='int')
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

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,
Ultima's avatar
Ultima committed
63
64
                      variable_use_healpy,
                      variable_use_libsharp,
65
66
67
68
69
                      variable_verbosity,
                      variable_mpi_module,
                      variable_default_distribution_strategy
                      ],
                     path=os.path.expanduser('~') + "/.nifty/global_config")
70
71
72
73
74
75
76
77
78


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)
79

Ultima's avatar
Ultima committed
80
81
82
83
try:
    global_configuration.load()
except:
    pass