Commit 45d4c21f authored by theos's avatar theos

Switched from `about` to keepers logging.

Removed NIFTy 2 files that have not been ported so far.
parent c53029ef
......@@ -26,25 +26,22 @@ mpl.use('Agg')
from .version import __version__
from logger import logger
import dummys
# it is important to import config before d2o such that NIFTy is able to
# pre-create d2o's configuration object with the corrected path
from config import about,\
dependency_injector,\
from config import dependency_injector,\
nifty_configuration,\
d2o_configuration
from d2o import distributed_data_object, d2o_librarian
from nifty_cmaps import ncmap
from field import Field
# this line exists for compatibility reasons
# TODO: Remove this once the transition to field types is done.
from spaces.space import Space as point_space
from random import Random
from nifty_simple_math import *
from nifty_utilities import *
......
# -*- coding: utf-8 -*-
from nifty_about import *
from nifty_config import dependency_injector,\
nifty_configuration
......
This diff is collapsed.
......@@ -258,7 +258,6 @@ class problem(object):
if(__name__=="__main__"):
x = RGSpace((1280), zerocenter=True)
p = problem(x, log = False)
about.warnings.off()
## pl.close("all")
#
# ## define signal space
......
......@@ -41,9 +41,6 @@ from __future__ import division
from nifty import *
about.warnings.off()
about.infos.off()
##-----------------------------------------------------------------------------
......
......@@ -4,9 +4,6 @@ from nifty import *
if __name__ == "__main__":
about.warnings.off()
shape = (256, 256)
x_space = RGSpace(shape)
......
......@@ -43,7 +43,6 @@ import gc
from nifty import * # version 0.8.0
if __name__ == "__main__":
about.warnings.off()
# some signal space; e.g., a two-dimensional regular grid
shape = [1024, 1024]
......
......@@ -4,8 +4,7 @@ import numpy as np
from d2o import distributed_data_object,\
STRATEGIES as DISTRIBUTION_STRATEGIES
from nifty.config import about,\
nifty_configuration as gc
from nifty.config import nifty_configuration as gc
from nifty.field_types import FieldType
......@@ -15,6 +14,9 @@ from nifty.spaces.power_space import PowerSpace
import nifty.nifty_utilities as utilities
from nifty.random import Random
import logging
logger = logging.getLogger('NIFTy.Field')
class Field(object):
# ---Initialization methods---
......@@ -58,9 +60,9 @@ class Field(object):
for d in domain:
if not isinstance(d, Space):
raise TypeError(about._errors.cstring(
"ERROR: Given domain contains something that is not a "
"nifty.space."))
raise TypeError(
"Given domain contains something that is not a "
"nifty.space.")
return domain
def _parse_field_type(self, field_type, val=None):
......@@ -75,8 +77,8 @@ class Field(object):
field_type = tuple(field_type)
for ft in field_type:
if not isinstance(ft, FieldType):
raise TypeError(about._errors.cstring(
"ERROR: Given object is not a nifty.FieldType."))
raise TypeError(
"Given object is not a nifty.FieldType.")
return field_type
def _get_axes_tuple(self, things_with_shape, start=0):
......@@ -114,12 +116,12 @@ class Field(object):
elif isinstance(val, Field):
distribution_strategy = val.distribution_strategy
else:
about.warnings.cprint("WARNING: Datamodel set to default!")
logger.info("Datamodel set to default!")
distribution_strategy = gc['default_distribution_strategy']
elif distribution_strategy not in DISTRIBUTION_STRATEGIES['global']:
raise ValueError(about._errors.cstring(
"ERROR: distribution_strategy must be a global-type "
"strategy."))
raise ValueError(
"distribution_strategy must be a global-type "
"strategy.")
return distribution_strategy
# ---Factory methods---
......@@ -165,12 +167,9 @@ class Field(object):
random_arguments = {'low': low,
'high': high}
# elif random_type == 'syn':
# pass
else:
raise KeyError(about._errors.cstring(
"ERROR: unsupported random key '" + str(random_type) + "'."))
raise KeyError(
"unsupported random key '" + str(random_type) + "'.")
return random_arguments
......@@ -183,7 +182,7 @@ class Field(object):
for sp in self.domain:
if not sp.harmonic and not isinstance(sp, PowerSpace):
raise AttributeError(
"ERROR: Field has a space in `domain` which is neither "
"Field has a space in `domain` which is neither "
"harmonic nor a PowerSpace.")
# check if the `spaces` input is valid
......@@ -192,22 +191,22 @@ class Field(object):
if len(self.domain) == 1:
spaces = (0,)
else:
raise ValueError(about._errors.cstring(
"ERROR: Field has multiple spaces as domain "
"but `spaces` is None."))
raise ValueError(
"Field has multiple spaces as domain "
"but `spaces` is None.")
if len(spaces) == 0:
raise ValueError(about._errors.cstring(
"ERROR: No space for analysis specified."))
raise ValueError(
"No space for analysis specified.")
elif len(spaces) > 1:
raise ValueError(about._errors.cstring(
"ERROR: Conversion of only one space at a time is allowed."))
raise ValueError(
"Conversion of only one space at a time is allowed.")
space_index = spaces[0]
if not self.domain[space_index].harmonic:
raise ValueError(about._errors.cstring(
"ERROR: The analyzed space must be harmonic."))
raise ValueError(
"The analyzed space must be harmonic.")
# Create the target PowerSpace instance:
# If the associated signal-space field was real, we extract the
......@@ -289,14 +288,14 @@ class Field(object):
def _shape_up_pindex(self, pindex, target_shape, target_strategy, axes):
if pindex.distribution_strategy not in \
DISTRIBUTION_STRATEGIES['global']:
raise ValueError("ERROR: pindex's distribution strategy must be "
raise ValueError("pindex's distribution strategy must be "
"global-type")
if pindex.distribution_strategy in DISTRIBUTION_STRATEGIES['slicing']:
if ((0 not in axes) or
(target_strategy is not pindex.distribution_strategy)):
raise ValueError(
"ERROR: A slicing distributor shall not be reshaped to "
"A slicing distributor shall not be reshaped to "
"something non-sliced.")
semiscaled_shape = [1, ] * len(target_shape)
......@@ -316,7 +315,7 @@ class Field(object):
for sp in self.domain:
if not sp.harmonic and not isinstance(sp, PowerSpace):
raise AttributeError(
"ERROR: Field has a space in `domain` which is neither "
"Field has a space in `domain` which is neither "
"harmonic nor a PowerSpace.")
# check if the `spaces` input is valid
......@@ -325,22 +324,22 @@ class Field(object):
if len(self.domain) == 1:
spaces = (0,)
else:
raise ValueError(about._errors.cstring(
"ERROR: Field has multiple spaces as domain "
"but `spaces` is None."))
raise ValueError(
"Field has multiple spaces as domain "
"but `spaces` is None.")
if len(spaces) == 0:
raise ValueError(about._errors.cstring(
"ERROR: No space for synthesis specified."))
raise ValueError(
"No space for synthesis specified.")
elif len(spaces) > 1:
raise ValueError(about._errors.cstring(
"ERROR: Conversion of only one space at a time is allowed."))
raise ValueError(
"Conversion of only one space at a time is allowed.")
power_space_index = spaces[0]
power_domain = self.domain[power_space_index]
if not isinstance(power_domain, PowerSpace):
raise ValueError(about._errors.cstring(
"ERROR: A PowerSpace is needed for field synthetization."))
raise ValueError(
"A PowerSpace is needed for field synthetization.")
# create the result domain
result_domain = list(self.domain)
......@@ -385,8 +384,8 @@ class Field(object):
result_list[0].domain_axes[power_space_index])
if pindex.distribution_strategy is not local_distribution_strategy:
about.warnings.cprint(
"WARNING: The distribution_stragey of pindex does not fit the "
logger.warn(
"The distribution_stragey of pindex does not fit the "
"slice_local distribution strategy of the synthesized field.")
# Now use numpy advanced indexing in order to put the entries of the
......@@ -623,8 +622,8 @@ class Field(object):
for index in xrange(len(self.field_type)):
assert x.field_type[index] == self.field_type[index]
except AssertionError:
raise ValueError(about._errors.cstring(
"ERROR: domains are incompatible."))
raise ValueError(
"domains are incompatible.")
# extract the data from x and try to dot with this
x = x.get_val(copy=False)
......@@ -788,8 +787,8 @@ class Field(object):
for index in xrange(len(self.field_type)):
assert other.field_type[index] == self.field_type[index]
except AssertionError:
raise ValueError(about._errors.cstring(
"ERROR: domains are incompatible."))
raise ValueError(
"domains are incompatible.")
other = other.get_val(copy=False)
self_val = self.get_val(copy=False)
......
# -*- coding: utf-8 -*-
from keepers import MPILogger
logger = MPILogger()
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -22,8 +22,6 @@
##-----------------------------------------------------------------------------
import numpy as np
#from nifty.field import Field
from nifty.config import about
def vdot(x, y):
......@@ -490,7 +488,7 @@ def log(x, base=None):
if np.all(base > 0):
return _math_helper(x, np.log)/np.log(base)
else:
raise ValueError(about._errors.cstring("ERROR: invalid input basis."))
raise ValueError("invalid input basis.")
def conjugate(x):
......
......@@ -3,8 +3,6 @@
import numpy as np
from itertools import product
from nifty.config import about
def get_slice_list(shape, axes):
"""
......@@ -32,14 +30,11 @@ def get_slice_list(shape, axes):
"""
if not shape:
raise ValueError(about._errors.cstring("ERROR: shape cannot be None."))
raise ValueError("shape cannot be None.")
if axes:
if not all(axis < len(shape) for axis in axes):
raise ValueError(
about._errors.cstring("ERROR: \
axes(axis) does not match shape.")
)
raise ValueError("axes(axis) does not match shape.")
axes_select = [0 if x in axes else 1 for x, y in enumerate(shape)]
axes_iterables = \
[range(y) for x, y in enumerate(shape) if x not in axes]
......@@ -234,7 +229,7 @@ def cast_axis_to_tuple(axis, length):
axis = (int(axis),)
else:
raise TypeError(
"ERROR: Could not convert axis-input to tuple of ints")
"Could not convert axis-input to tuple of ints")
# shift negative indices to positive ones
axis = tuple(item if (item >= 0) else (item + length) for item in axis)
......@@ -281,4 +276,4 @@ def get_default_codomain(domain):
# TODO: get the preferred transformation path from config
return LMGLTransformation.get_codomain(domain)
else:
raise TypeError(about._errors.cstring('ERROR: unknown domain'))
raise TypeError('ERROR: unknown domain')
......@@ -32,24 +32,3 @@ from smoothing_operator import SmoothingOperator
from fft_operator import *
from propagator_operator import PropagatorOperator
from nifty_operators import operator,\
diagonal_operator,\
power_operator,\
projection_operator,\
vecvec_operator,\
response_operator,\
invertible_operator,\
propagator_operator,\
identity,\
identity_operator
from nifty_probing import prober,\
trace_prober,\
inverse_trace_prober,\
diagonal_prober,\
inverse_diagonal_prober
from nifty_minimization import conjugate_gradient,\
steepest_descent
......@@ -5,11 +5,13 @@ import numpy as np
from d2o import distributed_data_object,\
STRATEGIES as DISTRIBUTION_STRATEGIES
from nifty.config import about,\
nifty_configuration as gc
from nifty.config import nifty_configuration as gc
from nifty.field import Field
from nifty.operators.endomorphic_operator import EndomorphicOperator
import logging
logger = logging.getLogger('NIFTy.DiagonalOperator')
class DiagonalOperator(EndomorphicOperator):
......@@ -117,11 +119,11 @@ class DiagonalOperator(EndomorphicOperator):
elif isinstance(val, Field):
distribution_strategy = val.distribution_strategy
else:
about.warnings.cprint("WARNING: Datamodel set to default!")
logger.info("Datamodel set to default!")
distribution_strategy = gc['default_distribution_strategy']
elif distribution_strategy not in DISTRIBUTION_STRATEGIES['all']:
raise ValueError(about._errors.cstring(
"ERROR: Invalid distribution_strategy!"))
raise ValueError(
"Invalid distribution_strategy!")
return distribution_strategy
def set_diagonal(self, diagonal, bare=False, copy=True):
......
from nifty.config import about
import nifty.nifty_utilities as utilities
from nifty.spaces import RGSpace,\
GLSpace,\
......@@ -40,15 +40,15 @@ class FFTOperator(LinearOperator):
# Initialize domain and target
if len(self.domain) != 1:
raise ValueError(about._errors.cstring(
raise ValueError(
'ERROR: TransformationOperator accepts only exactly one '
'space as input domain.'))
'space as input domain.')
if self.field_type != ():
raise ValueError(about._errors.cstring(
raise ValueError(
'ERROR: TransformationOperator field-type must be an '
'empty tuple.'
))
)
if target is None:
target = (self.get_default_codomain(self.domain[0]), )
......@@ -59,16 +59,16 @@ class FFTOperator(LinearOperator):
forward_class = self.transformation_dictionary[
(self.domain[0].__class__, self.target[0].__class__)]
except KeyError:
raise TypeError(about._errors.cstring(
"ERROR: No forward transformation for domain-target pair "
"found."))
raise TypeError(
"No forward transformation for domain-target pair "
"found.")
try:
backward_class = self.transformation_dictionary[
(self.target[0].__class__, self.domain[0].__class__)]
except KeyError:
raise TypeError(about._errors.cstring(
"ERROR: No backward transformation for domain-target pair "
"found."))
raise TypeError(
"No backward transformation for domain-target pair "
"found.")
self._forward_transformation = TransformationCache.create(
forward_class, self.domain[0], self.target[0], module=module)
......@@ -156,13 +156,13 @@ class FFTOperator(LinearOperator):
try:
codomain_class = cls.default_codomain_dictionary[domain_class]
except KeyError:
raise TypeError(about._errors.cstring("ERROR: unknown domain"))
raise TypeError("unknown domain")
try:
transform_class = cls.transformation_dictionary[(domain_class,
codomain_class)]
except KeyError:
raise TypeError(about._errors.cstring(
"ERROR: No transformation for domain-codomain pair found."))
raise TypeError(
"No transformation for domain-codomain pair found.")
return transform_class.get_codomain(domain)
import numpy as np
from nifty.config import dependency_injector as gdi,\
about
from nifty.config import dependency_injector as gdi
from nifty import GLSpace, LMSpace
from slicing_transformation import SlicingTransformation
import lm_transformation_factory as ltf
import logging
logger = logging.getLogger('NIFTy.GLLMTransformation')
libsharp = gdi.get('libsharp_wrapper_gl')
......@@ -14,8 +17,8 @@ class GLLMTransformation(SlicingTransformation):
def __init__(self, domain, codomain=None, module=None):
if 'libsharp_wrapper_gl' not in gdi:
raise ImportError(about._errors.cstring(
"The module libsharp is needed but not available."))
raise ImportError(
"The module libsharp is needed but not available.")
super(GLLMTransformation, self).__init__(domain, codomain, module)
......@@ -39,8 +42,8 @@ class GLLMTransformation(SlicingTransformation):
"""
if not isinstance(domain, GLSpace):
raise TypeError(about._errors.cstring(
"ERROR: domain needs to be a GLSpace"))
raise TypeError(
"domain needs to be a GLSpace")
nlat = domain.nlat
lmax = nlat - 1
......@@ -57,12 +60,12 @@ class GLLMTransformation(SlicingTransformation):
@staticmethod
def check_codomain(domain, codomain):
if not isinstance(domain, GLSpace):
raise TypeError(about._errors.cstring(
"ERROR: domain is not a GLSpace"))
raise TypeError(
"domain is not a GLSpace")
if not isinstance(codomain, LMSpace):
raise TypeError(about._errors.cstring(
"ERROR: codomain must be a LMSpace."))
raise TypeError(
"codomain must be a LMSpace.")
nlat = domain.nlat
nlon = domain.nlon
......@@ -70,16 +73,16 @@ class GLLMTransformation(SlicingTransformation):
mmax = codomain.mmax
if lmax != mmax:
raise ValueError(about._errors.cstring(
'ERROR: codomain has lmax != mmax.'))
raise ValueError(
'ERROR: codomain has lmax != mmax.')
if lmax != nlat - 1:
raise ValueError(about._errors.cstring(
'ERROR: codomain has lmax != nlat - 1.'))
raise ValueError(
'ERROR: codomain has lmax != nlat - 1.')
if nlon != 2 * nlat - 1:
raise ValueError(about._errors.cstring(
'ERROR: domain has nlon != 2 * nlat - 1.'))
raise ValueError(
'ERROR: domain has nlon != 2 * nlat - 1.')
return None
......@@ -118,8 +121,8 @@ class GLLMTransformation(SlicingTransformation):
elif inp.dtype == np.dtype('float64'):
return libsharp.map2alm(inp, **kwargs)
else:
about.warnings.cprint("WARNING: performing dtype conversion for "
"libsharp compatibility.")
logger.debug("performing dtype conversion for libsharp "
"compatibility.")
casted_inp = inp.astype(np.dtype('float64'), copy=False)
result = libsharp.map2alm(casted_inp, **kwargs)
return result
\ No newline at end of file
return result
import numpy as np
from nifty.config import dependency_injector as gdi,\
about
from nifty.config import dependency_injector as gdi
from nifty import HPSpace, LMSpace
from slicing_transformation import SlicingTransformation
......@@ -15,8 +15,8 @@ class HPLMTransformation(SlicingTransformation):
def __init__(self, domain, codomain=None, module=None):
if 'healpy' not in gdi:
raise ImportError(about._errors.cstring(
"The module healpy is needed but not available"))
raise ImportError(
"The module healpy is needed but not available")
super(HPLMTransformation, self).__init__(domain, codomain, module)
......@@ -40,8 +40,8 @@ class HPLMTransformation(SlicingTransformation):
"""
if not isinstance(domain, HPSpace):
raise TypeError(about._errors.cstring(
"ERROR: domain needs to be a HPSpace"))
raise TypeError(
"domain needs to be a HPSpace")
lmax = 3 * domain.nside - 1
......@@ -52,19 +52,19 @@ class HPLMTransformation(SlicingTransformation):
@staticmethod
def check_codomain(domain, codomain):
if not isinstance(domain, HPSpace):
raise TypeError(about._errors.cstring(
'ERROR: domain is not a HPSpace'))
raise TypeError(
'ERROR: domain is not a HPSpace')
if not isinstance(codomain, LMSpace):
raise TypeError(about._errors.cstring(
'ERROR: codomain must be a LMSpace.'))
raise TypeError(
'ERROR: codomain must be a LMSpace.')
nside = domain.nside
lmax = codomain.lmax
if 3 * nside - 1 != lmax:
raise ValueError(about._errors.cstring(
'ERROR: codomain has 3*nside-1 != lmax.'))
raise ValueError(
'ERROR: codomain has 3*nside-1 != lmax.')
return None
......
import numpy as np
from nifty.config import dependency_injector as gdi,\
about
from nifty.config import dependency_injector as gdi
from nifty import GLSpace, LMSpace
from slicing_transformation import SlicingTransformation
import lm_transformation_factory as ltf
import logging
logger = logging.getLogger('NIFTy.LMGLTransformation')
libsharp = gdi.get('libsharp_wrapper_gl')