Skip to content
GitLab
Menu
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
61e4b7a3
Commit
61e4b7a3
authored
Jul 04, 2016
by
theos
Browse files
Changed wording of LmSpace, GlSpace and HpSpace to PEP8 convention.
parent
38cd41a8
Changes
20
Hide whitespace changes
Inline
Side-by-side
__init__.py
View file @
61e4b7a3
...
...
@@ -60,7 +60,7 @@ from power import PowerSpace,\
## optional submodule `rg`
try
:
from
rg
import
R
g
Space
,
\
from
rg
import
R
G
Space
,
\
power_backward_conversion_rg
,
\
power_forward_conversion_rg
from
nifty_paradict
import
rg_space_paradict
...
...
@@ -69,19 +69,19 @@ except(ImportError):
## optional submodule `lm`
try
:
from
lm
import
L
m
Space
,
\
from
lm
import
L
M
Space
,
\
power_backward_conversion_lm
,
\
power_forward_conversion_lm
from
nifty_paradict
import
lm_space_paradict
try
:
from
lm
import
G
l
Space
from
lm
import
G
L
Space
from
nifty_paradict
import
gl_space_paradict
except
(
ImportError
):
pass
try
:
from
lm
import
H
p
Space
from
lm
import
H
P
Space
from
nifty_paradict
import
hp_space_paradict
except
(
ImportError
):
pass
...
...
demos/demo_excaliwir.py
View file @
61e4b7a3
...
...
@@ -256,7 +256,7 @@ class problem(object):
##-----------------------------------------------------------------------------
#
if
(
__name__
==
"__main__"
):
x
=
R
g
Space
((
1280
),
zerocenter
=
True
)
x
=
R
G
Space
((
1280
),
zerocenter
=
True
)
p
=
problem
(
x
,
log
=
False
)
about
.
warnings
.
off
()
## pl.close("all")
...
...
demos/demo_faraday.py
View file @
61e4b7a3
...
...
@@ -48,7 +48,7 @@ about.infos.off()
##-----------------------------------------------------------------------------
# (global) Faraday map
m
=
field
(
H
p
Space
(
128
),
val
=
np
.
load
(
os
.
path
.
join
(
get_demo_dir
(),
m
=
field
(
H
P
Space
(
128
),
val
=
np
.
load
(
os
.
path
.
join
(
get_demo_dir
(),
"demo_faraday_map.npy"
)))
##-----------------------------------------------------------------------------
...
...
@@ -98,8 +98,8 @@ def run(projection=False, power=False):
m4
.
plot
(
title
=
r
"angular quadrupole of $m$ on a Gauss-Legendre grid"
,
**
nicely
)
# (d) representation on regular grid
y_space
=
G
l
Space
(
384
,
nlon
=
768
)
# auxiliary gl_space
z_space
=
R
g
Space
([
768
,
384
],
dist
=
[
1
/
360
,
1
/
180
])
y_space
=
G
L
Space
(
384
,
nlon
=
768
)
# auxiliary gl_space
z_space
=
R
G
Space
([
768
,
384
],
dist
=
[
1
/
360
,
1
/
180
])
m5
=
m1
.
transform
(
y_space
)
m5
.
cast_domain
(
z_space
)
m5
.
set_val
(
np
.
roll
(
m5
.
val
[::
-
1
,
::
-
1
],
y_space
.
paradict
[
'nlon'
]
//
2
,
axis
=
1
))
# rearrange value array
...
...
demos/demo_tomography.py
View file @
61e4b7a3
...
...
@@ -9,7 +9,7 @@ if __name__ == "__main__":
shape
=
(
256
,
256
)
x_space
=
R
g
Space
(
shape
)
x_space
=
R
G
Space
(
shape
)
k_space
=
x_space
.
get_codomain
()
power
=
lambda
k
:
42
/
((
1
+
k
*
shape
[
0
])
**
3
)
...
...
demos/demo_wf1.py
View file @
61e4b7a3
...
...
@@ -49,8 +49,8 @@ if __name__ == "__main__":
#shape = [1024, 1024]
#x_space = rg_space(shape)
#y_space = point_space(1280*1280)
x_space
=
H
p
Space
(
32
)
#x_space = G
l
Space(800)
x_space
=
H
P
Space
(
32
)
#x_space = G
L
Space(800)
k_space
=
x_space
.
get_codomain
()
# get conjugate space
...
...
demos/demo_wf2.py
View file @
61e4b7a3
...
...
@@ -55,7 +55,7 @@ from nifty.operators.nifty_minimization import steepest_descent_new
if
__name__
==
"__main__"
:
# some signal space; e.g., a two-dimensional regular grid
x_space
=
R
g
Space
([
256
,
256
])
# define
x_space
=
R
G
Space
([
256
,
256
])
# define
# signal space
k_space
=
x_space
.
get_codomain
()
# get conjugate space
...
...
demos/demo_wf3.py
View file @
61e4b7a3
...
...
@@ -39,7 +39,7 @@ if __name__ == "__main__":
# some signal space; e.g., a one-dimensional regular grid
x_space
=
R
g
Space
([
128
,])
#
x_space
=
R
G
Space
([
128
,])
#
# define signal space
k_space
=
x_space
.
get_codomain
()
# get conjugate space
...
...
lm/__init__.py
View file @
61e4b7a3
...
...
@@ -38,8 +38,8 @@ except(ImportError):
"INFO: neither libsharp_wrapper_gl nor healpy available."
)
pass
## import nothing
else
:
from
lm_space
import
L
m
Space
## import lm & hp
from
hp_space
import
H
p
Space
from
lm_space
import
L
M
Space
## import lm & hp
from
hp_space
import
H
P
Space
## TODO: change about
else
:
try
:
...
...
@@ -49,13 +49,13 @@ else:
about
.
_errors
.
cprint
(
"ERROR: installed healpy version is older than 1.8.1!"
))
except
(
ImportError
):
from
gl_space
import
G
l
Space
## import lm & gl
from
lm_space
import
L
m
Space
from
gl_space
import
G
L
Space
## import lm & gl
from
lm_space
import
L
M
Space
else
:
from
gl_space
import
G
l
Space
##import all
from
lm_space
import
L
m
Space
from
hp_space
import
H
p
Space
from
gl_space
import
G
L
Space
##import all
from
lm_space
import
L
M
Space
from
hp_space
import
H
P
Space
from
nifty.lm.nifty_power_conversion_lm
import
power_backward_conversion_lm
,
\
power_forward_conversion_lm
power_forward_conversion_lm
lm/gl_space.py
View file @
61e4b7a3
...
...
@@ -7,6 +7,8 @@ from matplotlib.ticker import LogFormatter as lf
from
d2o
import
STRATEGIES
as
DISTRIBUTION_STRATEGIES
from
nifty.lm
import
LMSpace
from
nifty.space
import
Space
from
nifty.config
import
about
,
\
nifty_configuration
as
gc
,
\
...
...
@@ -18,7 +20,8 @@ gl = gdi.get('libsharp_wrapper_gl')
GL_DISTRIBUTION_STRATEGIES
=
DISTRIBUTION_STRATEGIES
[
'global'
]
class
GlSpace
(
Space
):
class
GLSpace
(
Space
):
"""
.. __
.. / /
...
...
@@ -129,9 +132,9 @@ class GlSpace(Space):
self
.
paradict
[
'nlon'
]
=
x
[
1
]
def
copy
(
self
):
return
G
l
Space
(
nlat
=
self
.
paradict
[
'nlat'
],
nlon
=
self
.
paradict
[
'nlon'
],
dtype
=
self
.
dtype
)
return
G
L
Space
(
nlat
=
self
.
paradict
[
'nlat'
],
nlon
=
self
.
paradict
[
'nlon'
],
dtype
=
self
.
dtype
)
@
property
def
shape
(
self
):
...
...
@@ -205,7 +208,7 @@ class GlSpace(Space):
if
not
isinstance
(
codomain
,
Space
):
raise
TypeError
(
about
.
_errors
.
cstring
(
"ERROR: invalid input."
))
if
isinstance
(
codomain
,
L
m
Space
):
if
isinstance
(
codomain
,
L
M
Space
):
nlat
=
self
.
paradict
[
'nlat'
]
nlon
=
self
.
paradict
[
'nlon'
]
lmax
=
codomain
.
paradict
[
'lmax'
]
...
...
@@ -233,9 +236,9 @@ class GlSpace(Space):
mmax
=
nlat
-
1
# lmax,mmax = nlat-1,nlat-1
if
self
.
dtype
==
np
.
dtype
(
'float32'
):
return
L
m
Space
(
lmax
=
lmax
,
mmax
=
mmax
,
dtype
=
np
.
complex64
)
return
L
M
Space
(
lmax
=
lmax
,
mmax
=
mmax
,
dtype
=
np
.
complex64
)
else
:
return
L
m
Space
(
lmax
=
lmax
,
mmax
=
mmax
,
dtype
=
np
.
complex128
)
return
L
M
Space
(
lmax
=
lmax
,
mmax
=
mmax
,
dtype
=
np
.
complex128
)
def
get_random_values
(
self
,
**
kwargs
):
"""
...
...
@@ -308,7 +311,7 @@ class GlSpace(Space):
sample
=
self
.
calc_weight
(
sample
,
power
=
0.5
)
else
:
sample
=
super
(
G
l
Space
,
self
).
get_random_values
(
**
arg
)
sample
=
super
(
G
L
Space
,
self
).
get_random_values
(
**
arg
)
# elif(arg['random'] == "uni"):
...
...
@@ -404,7 +407,7 @@ class GlSpace(Space):
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: unsupported codomain."
))
if
isinstance
(
codomain
,
L
m
Space
):
if
isinstance
(
codomain
,
L
M
Space
):
# weight if discrete
if
self
.
discrete
:
...
...
lm/hp_space.py
View file @
61e4b7a3
...
...
@@ -38,6 +38,8 @@ import pylab as pl
from
d2o
import
STRATEGIES
as
DISTRIBUTION_STRATEGIES
from
nifty.lm
import
LMSpace
from
nifty.space
import
Space
from
nifty.field
import
Field
...
...
@@ -51,7 +53,8 @@ hp = gdi.get('healpy')
HP_DISTRIBUTION_STRATEGIES
=
DISTRIBUTION_STRATEGIES
[
'global'
]
class
HpSpace
(
Space
):
class
HPSpace
(
Space
):
"""
.. __
.. / /
...
...
@@ -148,7 +151,7 @@ class HpSpace(Space):
self
.
paradict
[
'nside'
]
=
x
[
0
]
def
copy
(
self
):
return
H
p
Space
(
nside
=
self
.
paradict
[
'nside'
])
return
H
P
Space
(
nside
=
self
.
paradict
[
'nside'
])
@
property
def
shape
(
self
):
...
...
@@ -221,7 +224,7 @@ class HpSpace(Space):
if
not
isinstance
(
codomain
,
Space
):
raise
TypeError
(
about
.
_errors
.
cstring
(
"ERROR: invalid input."
))
if
isinstance
(
codomain
,
L
m
Space
):
if
isinstance
(
codomain
,
L
M
Space
):
nside
=
self
.
paradict
[
'nside'
]
lmax
=
codomain
.
paradict
[
'lmax'
]
mmax
=
codomain
.
paradict
[
'mmax'
]
...
...
@@ -244,7 +247,7 @@ class HpSpace(Space):
"""
lmax
=
3
*
self
.
paradict
[
'nside'
]
-
1
mmax
=
lmax
return
L
m
Space
(
lmax
=
lmax
,
mmax
=
mmax
,
dtype
=
np
.
dtype
(
'complex128'
))
return
L
M
Space
(
lmax
=
lmax
,
mmax
=
mmax
,
dtype
=
np
.
dtype
(
'complex128'
))
def
get_random_values
(
self
,
**
kwargs
):
"""
...
...
@@ -312,7 +315,7 @@ class HpSpace(Space):
sample
=
self
.
calc_weight
(
sample
,
power
=
0.5
)
else
:
sample
=
super
(
H
p
Space
,
self
).
get_random_values
(
**
arg
)
sample
=
super
(
H
P
Space
,
self
).
get_random_values
(
**
arg
)
# elif arg['random'] == "uni":
...
...
@@ -369,7 +372,7 @@ class HpSpace(Space):
np_x
=
x
.
get_full_data
()
if
isinstance
(
codomain
,
L
m
Space
):
if
isinstance
(
codomain
,
L
M
Space
):
# weight if discrete
if
self
.
discrete
:
x
=
self
.
calc_weight
(
x
,
power
=-
0.5
)
...
...
lm/lm_space.py
View file @
61e4b7a3
...
...
@@ -10,8 +10,8 @@ from matplotlib.ticker import LogFormatter as lf
from
d2o
import
STRATEGIES
as
DISTRIBUTION_STRATEGIES
from
nifty.space
import
Space
from
hp_space
import
H
p
Space
from
gl_space
import
G
l
Space
from
hp_space
import
H
P
Space
from
gl_space
import
G
L
Space
from
nifty.config
import
about
,
\
nifty_configuration
as
gc
,
\
dependency_injector
as
gdi
...
...
@@ -25,7 +25,7 @@ hp = gdi.get('healpy')
LM_DISTRIBUTION_STRATEGIES
=
DISTRIBUTION_STRATEGIES
[
'global'
]
class
L
m
Space
(
Space
):
class
L
M
Space
(
Space
):
"""
.. __
.. / /
...
...
@@ -168,9 +168,9 @@ class LmSpace(Space):
return
tuple
(
sorted
(
temp
))
def
copy
(
self
):
return
L
m
Space
(
lmax
=
self
.
paradict
[
'lmax'
],
mmax
=
self
.
paradict
[
'mmax'
],
dtype
=
self
.
dtype
)
return
L
M
Space
(
lmax
=
self
.
paradict
[
'lmax'
],
mmax
=
self
.
paradict
[
'mmax'
],
dtype
=
self
.
dtype
)
@
property
def
shape
(
self
):
...
...
@@ -294,7 +294,7 @@ class LmSpace(Space):
raise
TypeError
(
about
.
_errors
.
cstring
(
"ERROR: The given codomain must be a nifty lm_space."
))
elif
isinstance
(
codomain
,
G
l
Space
):
elif
isinstance
(
codomain
,
G
L
Space
):
# lmax==mmax
# nlat==lmax+1
# nlon==2*lmax+1
...
...
@@ -303,7 +303,7 @@ class LmSpace(Space):
(
codomain
.
paradict
[
'nlon'
]
==
2
*
self
.
paradict
[
'lmax'
]
+
1
)):
return
True
elif
isinstance
(
codomain
,
H
p
Space
):
elif
isinstance
(
codomain
,
H
P
Space
):
# lmax==mmax
# 3*nside-1==lmax
if
((
self
.
paradict
[
'lmax'
]
==
self
.
paradict
[
'mmax'
])
and
...
...
@@ -353,11 +353,11 @@ class LmSpace(Space):
raise
NotImplementedError
nlat
=
self
.
paradict
[
'lmax'
]
+
1
nlon
=
self
.
paradict
[
'lmax'
]
*
2
+
1
return
G
l
Space
(
nlat
=
nlat
,
nlon
=
nlon
,
dtype
=
new_dtype
)
return
G
L
Space
(
nlat
=
nlat
,
nlon
=
nlon
,
dtype
=
new_dtype
)
elif
coname
==
'hp'
or
(
coname
is
None
and
not
gc
[
'lm2gl'
]):
nside
=
(
self
.
paradict
[
'lmax'
]
+
1
)
//
3
return
H
p
Space
(
nside
=
nside
)
return
H
P
Space
(
nside
=
nside
)
else
:
raise
ValueError
(
about
.
_errors
.
cstring
(
...
...
@@ -434,7 +434,7 @@ class LmSpace(Space):
sample
=
gl
.
synalm
(
arg
[
'spec'
],
lmax
=
lmax
,
mmax
=
mmax
)
else
:
sample
=
super
(
L
m
Space
,
self
).
get_random_values
(
**
arg
)
sample
=
super
(
L
M
Space
,
self
).
get_random_values
(
**
arg
)
# elif arg['random'] == "uni":
# x = random.uni(dtype=self.dtype,
...
...
@@ -528,7 +528,7 @@ class LmSpace(Space):
np_x
=
x
.
get_full_data
()
if
isinstance
(
codomain
,
G
l
Space
):
if
isinstance
(
codomain
,
G
L
Space
):
nlat
=
codomain
.
paradict
[
'nlat'
]
nlon
=
codomain
.
paradict
[
'nlon'
]
lmax
=
self
.
paradict
[
'lmax'
]
...
...
@@ -543,7 +543,7 @@ class LmSpace(Space):
lmax
=
lmax
,
mmax
=
mmax
,
cl
=
False
)
Tx
=
codomain
.
cast
(
np_Tx
)
elif
isinstance
(
codomain
,
H
p
Space
):
elif
isinstance
(
codomain
,
H
P
Space
):
nside
=
codomain
.
paradict
[
'nside'
]
lmax
=
self
.
paradict
[
'lmax'
]
mmax
=
self
.
paradict
[
'mmax'
]
...
...
lm/nifty_power_conversion_lm.py
View file @
61e4b7a3
...
...
@@ -27,7 +27,7 @@ from nifty.field import Field
from
nifty.nifty_simple_math
import
sqrt
,
exp
,
log
def
power_backward_conversion_lm
(
k_space
,
p
,
mean
=
None
):
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
...
...
power/power_space.py
View file @
61e4b7a3
...
...
@@ -7,7 +7,7 @@ from nifty.nifty_paradict import power_space_paradict
class
PowerSpace
(
Space
):
def
__init__
(
self
,
d
type
=
np
.
dtype
(
'float'
),
distribution_strategy
=
'fftw'
,
def
__init__
(
self
,
d
istribution_strategy
,
dtype
=
np
.
dtype
(
'float'
)
,
log
=
False
,
nbin
=
None
,
binbounds
=
None
):
self
.
dtype
=
np
.
dtype
(
dtype
)
self
.
paradict
=
power_space_paradict
(
...
...
power/rg_power_space.py
View file @
61e4b7a3
...
...
@@ -13,13 +13,13 @@ class RGPowerSpace(PowerSpace):
binbounds
=
None
):
self
.
dtype
=
np
.
dtype
(
dtype
)
self
.
paradict
=
rg_power_space_paradict
(
shape
=
shape
,
dgrid
=
dgrid
,
zerocentered
=
zerocentered
,
distribution_strategy
=
distribution_strategy
,
log
=
log
,
nbin
=
nbin
,
binbounds
=
binbounds
)
shape
=
shape
,
dgrid
=
dgrid
,
zerocentered
=
zerocentered
,
distribution_strategy
=
distribution_strategy
,
log
=
log
,
nbin
=
nbin
,
binbounds
=
binbounds
)
# self.power_indices = RGPowerIndexFactory.get_power_indices(
# **self.paradict.parameters)
rg/__init__.py
View file @
61e4b7a3
...
...
@@ -20,7 +20,7 @@
## along with this program. If not, see <http://www.gnu.org/licenses/>.
from
__future__
import
division
from
nifty_rg
import
R
g
Space
,
\
from
nifty_rg
import
R
G
Space
,
\
utilities
from
nifty_power_conversion_rg
import
power_backward_conversion_rg
,
\
power_forward_conversion_rg
...
...
rg/nifty_rg.py
View file @
61e4b7a3
...
...
@@ -59,7 +59,7 @@ MPI = gdi[gc['mpi_module']]
RG_DISTRIBUTION_STRATEGIES
=
DISTRIBUTION_STRATEGIES
[
'global'
]
class
R
g
Space
(
Space
):
class
R
G
Space
(
Space
):
"""
.. _____ _______
.. / __/ / _ /
...
...
@@ -241,7 +241,7 @@ class RgSpace(Space):
return
tuple
(
sorted
(
temp
))
def
copy
(
self
):
return
R
g
Space
(
shape
=
self
.
paradict
[
'shape'
],
return
R
G
Space
(
shape
=
self
.
paradict
[
'shape'
],
complexity
=
self
.
paradict
[
'complexity'
],
zerocenter
=
self
.
paradict
[
'zerocenter'
],
distances
=
self
.
distances
,
...
...
@@ -353,7 +353,7 @@ class RgSpace(Space):
if
codomain
is
None
:
return
False
if
not
isinstance
(
codomain
,
R
g
Space
):
if
not
isinstance
(
codomain
,
R
G
Space
):
raise
TypeError
(
about
.
_errors
.
cstring
(
"ERROR: The given codomain must be a nifty rg_space."
))
...
...
@@ -461,7 +461,7 @@ class RgSpace(Space):
complexity
=
{
0
:
1
,
1
:
0
,
2
:
2
}[
self
.
paradict
[
'complexity'
]]
harmonic
=
bool
(
not
self
.
harmonic
)
new_space
=
R
g
Space
(
shape
,
new_space
=
R
G
Space
(
shape
,
zerocenter
=
cozerocenter
,
complexity
=
complexity
,
distances
=
distances
,
...
...
@@ -541,7 +541,7 @@ class RgSpace(Space):
# Case 1: uniform distribution over {-1,+1}/{1,i,-1,-i}
if
arg
[
'random'
]
==
'pm1'
and
not
hermitianizeQ
:
sample
=
super
(
R
g
Space
,
self
).
get_random_values
(
**
arg
)
sample
=
super
(
R
G
Space
,
self
).
get_random_values
(
**
arg
)
elif
arg
[
'random'
]
==
'pm1'
and
hermitianizeQ
:
sample
=
self
.
get_random_values
(
random
=
'uni'
,
vmin
=-
1
,
vmax
=
1
)
...
...
@@ -579,14 +579,14 @@ class RgSpace(Space):
# Case 2: normal distribution with zero-mean and a given standard
# deviation or variance
elif
arg
[
'random'
]
==
'gau'
:
sample
=
super
(
R
g
Space
,
self
).
get_random_values
(
**
arg
)
sample
=
super
(
R
G
Space
,
self
).
get_random_values
(
**
arg
)
if
hermitianizeQ
:
sample
=
utilities
.
hermitianize_gaussian
(
sample
)
# Case 3: uniform distribution
elif
arg
[
'random'
]
==
"uni"
and
not
hermitianizeQ
:
sample
=
super
(
R
g
Space
,
self
).
get_random_values
(
**
arg
)
sample
=
super
(
R
G
Space
,
self
).
get_random_values
(
**
arg
)
elif
arg
[
'random'
]
==
"uni"
and
hermitianizeQ
:
# For a hermitian uniform sample, generate a gaussian one
...
...
@@ -1614,6 +1614,6 @@ class RgSpace(Space):
fig
.
canvas
.
draw
()
def
__repr__
(
self
):
string
=
super
(
R
g
Space
,
self
).
__repr__
()
string
=
super
(
R
G
Space
,
self
).
__repr__
()
string
+=
repr
(
self
.
fft_machine
)
+
"
\n
"
return
string
test/test_nifty_fft.py
View file @
61e4b7a3
...
...
@@ -6,7 +6,7 @@ import d2o
class
TestFFTWTransform
(
unittest
.
TestCase
):
def
test_comm
(
self
):
x
=
nt
.
R
g
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
R
G
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
b
=
d2o
.
distributed_data_object
(
a
)
b
.
comm
=
[
1
,
2
,
3
]
# change comm to something not supported
...
...
@@ -14,14 +14,14 @@ class TestFFTWTransform(unittest.TestCase):
x
.
fft_machine
.
transform
(
b
,
x
,
x
.
get_codomain
())
def
test_shapemismatch
(
self
):
x
=
nt
.
R
g
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
R
G
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
b
=
x
.
cast
(
a
)
with
self
.
assertRaises
(
ValueError
):
x
.
fft_machine
.
transform
(
b
,
x
,
x
.
get_codomain
(),
axes
=
(
0
,
1
,
2
))
def
test_local_ndarray
(
self
):
x
=
nt
.
R
g
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
R
G
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
self
.
assertTrue
(
np
.
allclose
(
...
...
@@ -31,7 +31,7 @@ class TestFFTWTransform(unittest.TestCase):
)
def
test_local_notzero
(
self
):
x
=
nt
.
R
g
Space
(
8
,
fft_module
=
'pyfftw'
)
x
=
nt
.
R
G
Space
(
8
,
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
b
=
x
.
cast
(
a
)
self
.
assertTrue
(
...
...
@@ -42,7 +42,7 @@ class TestFFTWTransform(unittest.TestCase):
)
def
test_not
(
self
):
x
=
nt
.
R
g
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
R
G
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'not'
)
self
.
assertTrue
(
...
...
@@ -53,7 +53,7 @@ class TestFFTWTransform(unittest.TestCase):
)
def
test_mpi_axesnone
(
self
):
x
=
nt
.
R
g
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
R
G
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
b
=
x
.
cast
(
a
)
self
.
assertTrue
(
...
...
@@ -64,7 +64,7 @@ class TestFFTWTransform(unittest.TestCase):
)
def
test_mpi_axesnone_equal
(
self
):
x
=
nt
.
R
g
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
R
G
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'equal'
)
self
.
assertTrue
(
...
...
@@ -75,7 +75,7 @@ class TestFFTWTransform(unittest.TestCase):
)
def
test_mpi_axesall
(
self
):
x
=
nt
.
R
g
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
R
G
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
b
=
x
.
cast
(
a
)
self
.
assertTrue
(
...
...
@@ -86,7 +86,7 @@ class TestFFTWTransform(unittest.TestCase):
)
def
test_mpi_axesall_equal
(
self
):
x
=
nt
.
R
g
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
R
G
Space
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'equal'
)
self
.
assertTrue
(
...
...
@@ -97,7 +97,7 @@ class TestFFTWTransform(unittest.TestCase):
)
def
test_mpi_zero
(
self
):
x
=
nt
.
R
g
Space
(
8
,
fft_module
=
'pyfftw'
)
x
=
nt
.
R
G
Space
(
8
,
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
+
1j
*
np
.
zeros
((
8
,
8
))
b
=
x
.
cast
(
a
)
self
.
assertTrue
(
...
...
@@ -108,7 +108,7 @@ class TestFFTWTransform(unittest.TestCase):
)
def
test_mpi_zero_equal
(
self
):
x
=
nt
.
R
g
Space
(
8
,
fft_module
=
'pyfftw'
)
x
=
nt
.
R
G
Space
(
8
,
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
+
1j
*
np
.
zeros
((
8
,
8
))
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'equal'
)
self
.
assertTrue
(
...
...
@@ -119,7 +119,7 @@ class TestFFTWTransform(unittest.TestCase):
)
def
test_mpi_zero_not
(
self
):
x
=
nt
.
R
g
Space
(
8
,
fft_module
=
'pyfftw'
)
x
=
nt
.
R
G
Space
(
8
,
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
+
1j
*
np
.
zeros
((
8
,
8
))
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'not'
)
self
.
assertTrue
(
...
...
test/test_nifty_field.py
View file @
61e4b7a3
...
...
@@ -14,7 +14,7 @@ from d2o import distributed_data_object
from
nifty
import
Space
,
\
point_space
from
nifty.rg
import
R
g
Space
from
nifty.rg
import
R
G
Space
from
nifty.lm
import
*
...
...
@@ -95,7 +95,7 @@ for param in itertools.product([(1,), (4, 6), (5, 8)],
[
False
],
DATAMODELS
[
'rg_space'
],
fft_modules
):
space_list
+=
[[
R
g
Space
(
shape
=
param
[
0
],
space_list
+=
[[
R
G
Space
(
shape
=
param
[
0
],
zerocenter
=
param
[
1
],
complexity
=
param
[
2
],
distances
=
param
[
3
],
...
...
@@ -106,10 +106,10 @@ for param in itertools.product([(1,), (4, 6), (5, 8)],
def
generate_space_with_size
(
name
,
num
):
space_dict
=
{
'space'
:
Space
(),
'point_space'
:
point_space
(
num
),
'rg_space'
:
R
g
Space
((
num
,
num
)),
'lm_space'
:
L
m
Space
(
mmax
=
num
+
1
,
lmax
=
num
+
1
),
'hp_space'
:
H
p
Space
(
num
),
'gl_space'
:
G
l
Space
(
nlat
=
num
,
nlon
=
2
*
num
-
1
),
'rg_space'
:
R
G
Space
((
num
,
num
)),
'lm_space'
:
L
M
Space
(
mmax
=
num
+
1
,
lmax
=
num
+
1
),
'hp_space'
:
H
P
Space
(
num
),
'gl_space'
:
G
L
Space
(
nlat
=
num
,
nlon
=
2
*
num
-
1
),
}
return
space_dict
[
name
]
...
...
@@ -135,7 +135,7 @@ class Test_field_init(unittest.TestCase):
def
test_successfull_init_and_attributes
(
self
,
shape
,
zerocenter
,
complexity
,
distances
,
harmonic
,
fft_module
,
datamodel
):
s
=
R
g
Space
(
shape
=
shape
,
zerocenter
=
zerocenter
,
s
=
R
G
Space
(
shape
=
shape
,
zerocenter
=
zerocenter
,
complexity
=
complexity
,
distances
=
distances
,
harmonic
=
harmonic
,
fft_module
=
fft_module
)
f
=
Field
(
domain
=
(
s
,),
dtype
=
s
.
dtype
,
datamodel
=
datamodel
)
...
...
@@ -171,10 +171,10 @@ class Test_field_multiple_rg_init(unittest.TestCase):
def
test_multiple_space_init
(
self
,
shape
,
zerocenter
,