Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
bc3f10ca
Commit
bc3f10ca
authored
May 24, 2016
by
csongor
Browse files
WIP: remove datamodel from spaces.
parent
5cbe6880
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
lm/nifty_lm.py
View file @
bc3f10ca
...
...
@@ -121,7 +121,7 @@ class lm_space(point_space):
"""
def
__init__
(
self
,
lmax
,
mmax
=
None
,
dtype
=
np
.
dtype
(
'complex128'
),
datamodel
=
'not'
,
comm
=
gc
[
'default_comm'
]):
comm
=
gc
[
'default_comm'
]):
"""
Sets the attributes for an lm_space class instance.
...
...
@@ -166,16 +166,6 @@ class lm_space(point_space):
dtype
=
np
.
dtype
(
'complex128'
)
self
.
dtype
=
dtype
# set datamodel
if
datamodel
not
in
[
'not'
]:
about
.
warnings
.
cprint
(
"WARNING: %s is not a recommended datamodel for lm_space."
%
datamodel
)
if
datamodel
not
in
LM_DISTRIBUTION_STRATEGIES
:
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: %s is not a valid datamodel"
%
datamodel
))
self
.
datamodel
=
datamodel
self
.
discrete
=
True
self
.
harmonic
=
True
self
.
distances
=
(
np
.
float
(
1
),)
...
...
@@ -185,7 +175,6 @@ class lm_space(point_space):
lmax
=
self
.
paradict
[
'lmax'
],
dim
=
self
.
get_dim
(),
comm
=
self
.
comm
,
datamodel
=
self
.
datamodel
,
allowed_distribution_strategies
=
LM_DISTRIBUTION_STRATEGIES
)
@
property
...
...
@@ -337,9 +326,6 @@ class lm_space(point_space):
if
self
.
comm
is
not
codomain
.
comm
:
return
False
if
self
.
datamodel
is
not
codomain
.
datamodel
:
return
False
elif
isinstance
(
codomain
,
gl_space
):
# lmax==mmax
# nlat==lmax+1
...
...
@@ -400,13 +386,11 @@ class lm_space(point_space):
nlat
=
self
.
paradict
[
'lmax'
]
+
1
nlon
=
self
.
paradict
[
'lmax'
]
*
2
+
1
return
gl_space
(
nlat
=
nlat
,
nlon
=
nlon
,
dtype
=
new_dtype
,
datamodel
=
self
.
datamodel
,
comm
=
self
.
comm
)
elif
coname
==
'hp'
or
(
coname
is
None
and
not
gc
[
'lm2gl'
]):
nside
=
(
self
.
paradict
[
'lmax'
]
+
1
)
//
3
return
hp_space
(
nside
=
nside
,
datamodel
=
self
.
datamodel
,
comm
=
self
.
comm
)
else
:
...
...
@@ -557,10 +541,10 @@ class lm_space(point_space):
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: unsupported codomain."
))
if
self
.
datamodel
!=
'not'
:
about
.
warnings
.
cprint
(
"WARNING: Field data is consolidated to all nodes for "
"external alm2map method!"
)
#
if self.datamodel != 'not':
#
about.warnings.cprint(
#
"WARNING: Field data is consolidated to all nodes for "
#
"external alm2map method!")
np_x
=
x
.
get_full_data
()
...
...
@@ -630,10 +614,10 @@ class lm_space(point_space):
elif
sigma
<
0
:
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: invalid sigma."
))
if
self
.
datamodel
!=
'not'
:
about
.
warnings
.
cprint
(
"WARNING: Field data is consolidated to all nodes for "
"external smoothalm method!"
)
#
if self.datamodel != 'not':
#
about.warnings.cprint(
#
"WARNING: Field data is consolidated to all nodes for "
#
"external smoothalm method!")
np_x
=
x
.
get_full_data
()
...
...
@@ -673,10 +657,10 @@ class lm_space(point_space):
lmax
=
self
.
paradict
[
'lmax'
]
mmax
=
self
.
paradict
[
'mmax'
]
if
self
.
datamodel
!=
'not'
:
about
.
warnings
.
cprint
(
"WARNING: Field data is consolidated to all nodes for "
"external anaalm/alm2cl method!"
)
#
if self.datamodel != 'not':
#
about.warnings.cprint(
#
"WARNING: Field data is consolidated to all nodes for "
#
"external anaalm/alm2cl method!")
np_x
=
x
.
get_full_data
()
...
...
@@ -964,7 +948,7 @@ class gl_space(point_space):
"""
def
__init__
(
self
,
nlat
,
nlon
=
None
,
dtype
=
np
.
dtype
(
'float64'
),
datamodel
=
'not'
,
comm
=
gc
[
'default_comm'
]):
comm
=
gc
[
'default_comm'
]):
"""
Sets the attributes for a gl_space class instance.
...
...
@@ -1004,16 +988,6 @@ class gl_space(point_space):
dtype
=
np
.
dtype
(
'float'
)
self
.
dtype
=
dtype
# set datamodel
if
datamodel
not
in
[
'not'
]:
about
.
warnings
.
cprint
(
"WARNING: %s is not a recommended datamodel for gl_space."
%
datamodel
)
if
datamodel
not
in
GL_DISTRIBUTION_STRATEGIES
:
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: %s is not a valid datamodel"
%
datamodel
))
self
.
datamodel
=
datamodel
self
.
discrete
=
False
self
.
harmonic
=
False
self
.
distances
=
tuple
(
gl
.
vol
(
self
.
paradict
[
'nlat'
],
...
...
@@ -1125,9 +1099,6 @@ class gl_space(point_space):
if
not
isinstance
(
codomain
,
space
):
raise
TypeError
(
about
.
_errors
.
cstring
(
"ERROR: invalid input."
))
if
self
.
datamodel
is
not
codomain
.
datamodel
:
return
False
if
self
.
comm
is
not
codomain
.
comm
:
return
False
...
...
@@ -1160,11 +1131,9 @@ class gl_space(point_space):
# lmax,mmax = nlat-1,nlat-1
if
self
.
dtype
==
np
.
dtype
(
'float32'
):
return
lm_space
(
lmax
=
lmax
,
mmax
=
mmax
,
dtype
=
np
.
complex64
,
datamodel
=
self
.
datamodel
,
comm
=
self
.
comm
)
else
:
return
lm_space
(
lmax
=
lmax
,
mmax
=
mmax
,
dtype
=
np
.
complex128
,
datamodel
=
self
.
datamodel
,
comm
=
self
.
comm
)
def
get_random_values
(
self
,
**
kwargs
):
...
...
@@ -1271,10 +1240,10 @@ class gl_space(point_space):
"""
x
=
self
.
cast
(
x
)
if
self
.
datamodel
!=
'not'
:
about
.
warnings
.
cprint
(
"WARNING: Field data is consolidated to all nodes for "
"external alm2map method!"
)
#
if self.datamodel != 'not':
#
about.warnings.cprint(
#
"WARNING: Field data is consolidated to all nodes for "
#
"external alm2map method!")
np_x
=
x
.
get_full_data
()
# weight
...
...
@@ -1344,10 +1313,10 @@ class gl_space(point_space):
lmax
=
codomain
.
paradict
[
'lmax'
]
mmax
=
codomain
.
paradict
[
'mmax'
]
if
self
.
datamodel
!=
'not'
:
about
.
warnings
.
cprint
(
"WARNING: Field data is consolidated to all nodes for "
"external map2alm method!"
)
#
if self.datamodel != 'not':
#
about.warnings.cprint(
#
"WARNING: Field data is consolidated to all nodes for "
#
"external map2alm method!")
np_x
=
x
.
get_full_data
()
...
...
@@ -1396,10 +1365,10 @@ class gl_space(point_space):
# smooth
nlat
=
self
.
paradict
[
'nlat'
]
if
self
.
datamodel
!=
'not'
:
about
.
warnings
.
cprint
(
"WARNING: Field data is consolidated to all nodes for "
"external smoothmap method!"
)
#
if self.datamodel != 'not':
#
about.warnings.cprint(
#
"WARNING: Field data is consolidated to all nodes for "
#
"external smoothmap method!")
np_x
=
x
.
get_full_data
()
...
...
@@ -1434,10 +1403,10 @@ class gl_space(point_space):
lmax
=
nlat
-
1
mmax
=
nlat
-
1
if
self
.
datamodel
!=
'not'
:
about
.
warnings
.
cprint
(
"WARNING: Field data is consolidated to all nodes for "
"external anafast method!"
)
#
if self.datamodel != 'not':
#
about.warnings.cprint(
#
"WARNING: Field data is consolidated to all nodes for "
#
"external anafast method!")
np_x
=
x
.
get_full_data
()
...
...
@@ -1657,7 +1626,7 @@ class hp_space(point_space):
An array with one element containing the pixel size.
"""
def
__init__
(
self
,
nside
,
datamodel
=
'not'
,
comm
=
gc
[
'default_comm'
]):
def
__init__
(
self
,
nside
,
comm
=
gc
[
'default_comm'
]):
"""
Sets the attributes for a hp_space class instance.
...
...
@@ -1690,16 +1659,6 @@ class hp_space(point_space):
self
.
dtype
=
np
.
dtype
(
'float64'
)
# set datamodel
if
datamodel
not
in
[
'not'
]:
about
.
warnings
.
cprint
(
"WARNING: %s is not a recommended datamodel for hp_space."
%
datamodel
)
if
datamodel
not
in
HP_DISTRIBUTION_STRATEGIES
:
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: %s is not a valid datamodel"
%
datamodel
))
self
.
datamodel
=
datamodel
self
.
discrete
=
False
self
.
harmonic
=
False
self
.
distances
=
(
np
.
float
(
4
*
np
.
pi
/
(
12
*
self
.
paradict
[
'nside'
]
**
2
)),)
...
...
@@ -1804,9 +1763,6 @@ class hp_space(point_space):
if
not
isinstance
(
codomain
,
space
):
raise
TypeError
(
about
.
_errors
.
cstring
(
"ERROR: invalid input."
))
if
self
.
datamodel
is
not
codomain
.
datamodel
:
return
False
if
self
.
comm
is
not
codomain
.
comm
:
return
False
...
...
@@ -1834,7 +1790,6 @@ class hp_space(point_space):
lmax
=
3
*
self
.
paradict
[
'nside'
]
-
1
mmax
=
lmax
return
lm_space
(
lmax
=
lmax
,
mmax
=
mmax
,
dtype
=
np
.
dtype
(
'complex128'
),
datamodel
=
self
.
datamodel
,
comm
=
self
.
comm
)
def
get_random_values
(
self
,
**
kwargs
):
...
...
@@ -1952,10 +1907,11 @@ class hp_space(point_space):
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: unsupported codomain."
))
if
self
.
datamodel
!=
'not'
:
about
.
warnings
.
cprint
(
"WARNING: Field data is consolidated to all nodes for "
"external map2alm method!"
)
# TODO look at these kinds of checks maybe need replacement
# if self.datamodel != 'not':
# about.warnings.cprint(
# "WARNING: Field data is consolidated to all nodes for "
# "external map2alm method!")
np_x
=
x
.
get_full_data
()
...
...
@@ -2015,10 +1971,10 @@ class hp_space(point_space):
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: invalid sigma."
))
# smooth
if
self
.
datamodel
!=
'not'
:
about
.
warnings
.
cprint
(
"WARNING: Field data is consolidated to all nodes for "
"external smoothalm method!"
)
#
if self.datamodel != 'not':
#
about.warnings.cprint(
#
"WARNING: Field data is consolidated to all nodes for "
#
"external smoothalm method!")
np_x
=
x
.
get_full_data
()
...
...
@@ -2059,10 +2015,10 @@ class hp_space(point_space):
lmax
=
3
*
nside
-
1
mmax
=
lmax
if
self
.
datamodel
!=
'not'
:
about
.
warnings
.
cprint
(
"WARNING: Field data is consolidated to all nodes for "
"external smoothalm method!"
)
#
if self.datamodel != 'not':
#
about.warnings.cprint(
#
"WARNING: Field data is consolidated to all nodes for "
#
"external smoothalm method!")
np_x
=
x
.
get_full_data
()
...
...
nifty_core.py
View file @
bc3f10ca
...
...
@@ -272,7 +272,7 @@ class space(object):
raise
NotImplementedError
(
about
.
_errors
.
cstring
(
"ERROR: no generic instance method 'getitem'."
))
def
setitem
(
self
,
data
,
key
):
def
setitem
(
self
,
data
,
update
,
key
):
raise
NotImplementedError
(
about
.
_errors
.
cstring
(
"ERROR: no generic instance method 'getitem'."
))
...
...
@@ -785,7 +785,7 @@ class point_space(space):
Pixel volume of the :py:class:`point_space`, which is always 1.
"""
def
__init__
(
self
,
num
,
dtype
=
np
.
dtype
(
'float'
),
datamodel
=
'fftw'
,
def
__init__
(
self
,
num
,
dtype
=
np
.
dtype
(
'float'
),
comm
=
gc
[
'default_comm'
]):
"""
Sets the attributes for a point_space class instance.
...
...
@@ -818,13 +818,6 @@ class point_space(space):
"WARNING: incompatible dtype: "
+
str
(
dtype
)))
self
.
dtype
=
dtype
if
datamodel
not
in
POINT_DISTRIBUTION_STRATEGIES
:
about
.
_errors
.
cstring
(
"WARNING: datamodel set to default."
)
self
.
datamodel
=
\
gc
[
'default_distribution_strategy'
]
else
:
self
.
datamodel
=
datamodel
self
.
comm
=
self
.
_parse_comm
(
comm
)
self
.
discrete
=
True
# self.harmonic = False
...
...
@@ -880,7 +873,6 @@ class point_space(space):
def
copy
(
self
):
return
point_space
(
num
=
self
.
paradict
[
'num'
],
dtype
=
self
.
dtype
,
datamodel
=
self
.
datamodel
,
comm
=
self
.
comm
)
def
getitem
(
self
,
data
,
key
):
...
...
@@ -1108,13 +1100,8 @@ class point_space(space):
"loss of precision!
\n
"
)
to_copy
=
True
# Check the distribution_strategy
if
x
.
distribution_strategy
!=
self
.
datamodel
:
to_copy
=
True
if
to_copy
:
temp
=
x
.
copy_empty
(
dtype
=
dtype
,
distribution_strategy
=
self
.
datamodel
)
temp
=
x
.
copy_empty
(
dtype
=
dtype
)
temp
.
set_data
(
to_key
=
(
slice
(
None
),),
data
=
x
,
from_key
=
(
slice
(
None
),))
...
...
@@ -1128,8 +1115,7 @@ class point_space(space):
else
:
x
=
distributed_data_object
(
x
,
global_shape
=
self
.
get_shape
(),
dtype
=
dtype
,
distribution_strategy
=
self
.
datamodel
)
dtype
=
dtype
)
# Cast the d2o
return
self
.
cast
(
x
,
dtype
=
dtype
)
...
...
@@ -1327,8 +1313,7 @@ class point_space(space):
# Prepare the empty distributed_data_object
sample
=
distributed_data_object
(
global_shape
=
self
.
get_shape
(),
dtype
=
self
.
dtype
,
distribution_strategy
=
self
.
datamodel
)
dtype
=
self
.
dtype
)
# Case 1: uniform distribution over {-1,+1}/{1,i,-1,-i}
if
arg
[
'random'
]
==
'pm1'
:
...
...
@@ -1632,7 +1617,6 @@ class point_space(space):
string
+=
str
(
type
(
self
))
+
"
\n
"
string
+=
"paradict: "
+
str
(
self
.
paradict
)
+
"
\n
"
string
+=
'dtype: '
+
str
(
self
.
dtype
)
+
"
\n
"
string
+=
'datamodel: '
+
str
(
self
.
datamodel
)
+
"
\n
"
string
+=
'comm: '
+
self
.
comm
.
name
+
"
\n
"
string
+=
'discrete: '
+
str
(
self
.
discrete
)
+
"
\n
"
string
+=
'distances: '
+
str
(
self
.
distances
)
+
"
\n
"
...
...
rg/nifty_rg.py
View file @
bc3f10ca
...
...
@@ -122,7 +122,7 @@ class rg_space(point_space):
epsilon
=
0.0001
# relative precision for comparisons
def
__init__
(
self
,
shape
,
zerocenter
=
False
,
complexity
=
0
,
distances
=
None
,
harmonic
=
False
,
datamodel
=
'fftw'
,
fft_module
=
gc
[
'fft_module'
],
harmonic
=
False
,
fft_module
=
gc
[
'fft_module'
],
comm
=
gc
[
'default_comm'
]):
"""
Sets the attributes for an rg_space class instance.
...
...
@@ -163,14 +163,6 @@ class rg_space(point_space):
else
:
self
.
dtype
=
np
.
dtype
(
'complex128'
)
# set datamodel
if
datamodel
not
in
[
'np'
]
+
RG_DISTRIBUTION_STRATEGIES
:
about
.
warnings
.
cprint
(
"WARNING: datamodel set to default."
)
self
.
datamodel
=
\
gc
[
'default_distribution_strategy'
]
else
:
self
.
datamodel
=
datamodel
# set volume/distances
naxes
=
len
(
self
.
paradict
[
'shape'
])
if
distances
is
None
:
...
...
@@ -210,7 +202,6 @@ class rg_space(point_space):
dgrid
=
distances
,
zerocentered
=
self
.
paradict
[
'zerocenter'
],
comm
=
self
.
comm
,
datamodel
=
self
.
datamodel
,
allowed_distribution_strategies
=
RG_DISTRIBUTION_STRATEGIES
)
@
property
...
...
@@ -257,7 +248,6 @@ class rg_space(point_space):
zerocenter
=
self
.
paradict
[
'zerocenter'
],
distances
=
self
.
distances
,
harmonic
=
self
.
harmonic
,
datamodel
=
self
.
datamodel
,
fft_module
=
self
.
fft_machine
.
name
,
comm
=
self
.
comm
)
...
...
@@ -376,9 +366,6 @@ class rg_space(point_space):
raise
TypeError
(
about
.
_errors
.
cstring
(
"ERROR: The given codomain must be a nifty rg_space."
))
if
self
.
datamodel
is
not
codomain
.
datamodel
:
return
False
if
self
.
comm
is
not
codomain
.
comm
:
return
False
...
...
@@ -482,7 +469,6 @@ class rg_space(point_space):
shape
=
self
.
paradict
[
'shape'
]
distances
=
1
/
(
np
.
array
(
self
.
paradict
[
'shape'
])
*
np
.
array
(
self
.
distances
))
datamodel
=
self
.
datamodel
fft_module
=
self
.
fft_machine
.
name
comm
=
self
.
comm
complexity
=
{
0
:
1
,
1
:
0
,
2
:
2
}[
self
.
paradict
[
'complexity'
]]
...
...
@@ -493,7 +479,6 @@ class rg_space(point_space):
complexity
=
complexity
,
distances
=
distances
,
harmonic
=
harmonic
,
datamodel
=
datamodel
,
fft_module
=
fft_module
,
comm
=
comm
)
return
new_space
...
...
@@ -929,8 +914,9 @@ class rg_space(point_space):
x
=
self
.
cast
(
x
)
# if x is hermitian it remains hermitian during smoothing
if
self
.
datamodel
in
RG_DISTRIBUTION_STRATEGIES
:
remeber_hermitianQ
=
x
.
hermitian
# TODO look at this later
# if self.datamodel in RG_DISTRIBUTION_STRATEGIES:
remeber_hermitianQ
=
x
.
hermitian
# Define the Gaussian kernel function
gaussian
=
lambda
x
:
np
.
exp
(
-
2.
*
np
.
pi
**
2
*
x
**
2
*
sigma
**
2
)
...
...
test/test_nifty_spaces.py
View file @
bc3f10ca
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment