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
d349bf74
Commit
d349bf74
authored
Jul 04, 2016
by
csongor
Browse files
Move Space classes in separate files
parent
0677d4f0
Changes
19
Expand all
Hide whitespace changes
Inline
Side-by-side
__init__.py
View file @
d349bf74
...
@@ -60,7 +60,7 @@ from power import PowerSpace,\
...
@@ -60,7 +60,7 @@ from power import PowerSpace,\
## optional submodule `rg`
## optional submodule `rg`
try
:
try
:
from
rg
import
rg_s
pace
,
\
from
rg
import
RgS
pace
,
\
power_backward_conversion_rg
,
\
power_backward_conversion_rg
,
\
power_forward_conversion_rg
power_forward_conversion_rg
from
nifty_paradict
import
rg_space_paradict
from
nifty_paradict
import
rg_space_paradict
...
@@ -69,19 +69,19 @@ except(ImportError):
...
@@ -69,19 +69,19 @@ except(ImportError):
## optional submodule `lm`
## optional submodule `lm`
try
:
try
:
from
lm
import
lm_s
pace
,
\
from
lm
import
LmS
pace
,
\
power_backward_conversion_lm
,
\
power_backward_conversion_lm
,
\
power_forward_conversion_lm
power_forward_conversion_lm
from
nifty_paradict
import
lm_space_paradict
from
nifty_paradict
import
lm_space_paradict
try
:
try
:
from
lm
import
gl_s
pace
from
lm
import
GlS
pace
from
nifty_paradict
import
gl_space_paradict
from
nifty_paradict
import
gl_space_paradict
except
(
ImportError
):
except
(
ImportError
):
pass
pass
try
:
try
:
from
lm
import
hp_s
pace
from
lm
import
HpS
pace
from
nifty_paradict
import
hp_space_paradict
from
nifty_paradict
import
hp_space_paradict
except
(
ImportError
):
except
(
ImportError
):
pass
pass
...
...
demos/demo_excaliwir.py
View file @
d349bf74
...
@@ -256,7 +256,7 @@ class problem(object):
...
@@ -256,7 +256,7 @@ class problem(object):
##-----------------------------------------------------------------------------
##-----------------------------------------------------------------------------
#
#
if
(
__name__
==
"__main__"
):
if
(
__name__
==
"__main__"
):
x
=
rg_s
pace
((
1280
),
zerocenter
=
True
)
x
=
RgS
pace
((
1280
),
zerocenter
=
True
)
p
=
problem
(
x
,
log
=
False
)
p
=
problem
(
x
,
log
=
False
)
about
.
warnings
.
off
()
about
.
warnings
.
off
()
## pl.close("all")
## pl.close("all")
...
...
demos/demo_faraday.py
View file @
d349bf74
...
@@ -48,7 +48,8 @@ about.infos.off()
...
@@ -48,7 +48,8 @@ about.infos.off()
##-----------------------------------------------------------------------------
##-----------------------------------------------------------------------------
# (global) Faraday map
# (global) Faraday map
m
=
field
(
hp_space
(
128
),
val
=
np
.
load
(
os
.
path
.
join
(
get_demo_dir
(),
"demo_faraday_map.npy"
)))
m
=
field
(
HpSpace
(
128
),
val
=
np
.
load
(
os
.
path
.
join
(
get_demo_dir
(),
"demo_faraday_map.npy"
)))
##-----------------------------------------------------------------------------
##-----------------------------------------------------------------------------
...
@@ -97,8 +98,8 @@ def run(projection=False, power=False):
...
@@ -97,8 +98,8 @@ def run(projection=False, power=False):
m4
.
plot
(
title
=
r
"angular quadrupole of $m$ on a Gauss-Legendre grid"
,
**
nicely
)
m4
.
plot
(
title
=
r
"angular quadrupole of $m$ on a Gauss-Legendre grid"
,
**
nicely
)
# (d) representation on regular grid
# (d) representation on regular grid
y_space
=
gl_s
pace
(
384
,
nlon
=
768
)
# auxiliary gl_space
y_space
=
GlS
pace
(
384
,
nlon
=
768
)
# auxiliary gl_space
z_space
=
rg_s
pace
([
768
,
384
],
dist
=
[
1
/
360
,
1
/
180
])
z_space
=
RgS
pace
([
768
,
384
],
dist
=
[
1
/
360
,
1
/
180
])
m5
=
m1
.
transform
(
y_space
)
m5
=
m1
.
transform
(
y_space
)
m5
.
cast_domain
(
z_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
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 @
d349bf74
...
@@ -9,7 +9,7 @@ if __name__ == "__main__":
...
@@ -9,7 +9,7 @@ if __name__ == "__main__":
shape
=
(
256
,
256
)
shape
=
(
256
,
256
)
x_space
=
rg_s
pace
(
shape
)
x_space
=
RgS
pace
(
shape
)
k_space
=
x_space
.
get_codomain
()
k_space
=
x_space
.
get_codomain
()
power
=
lambda
k
:
42
/
((
1
+
k
*
shape
[
0
])
**
3
)
power
=
lambda
k
:
42
/
((
1
+
k
*
shape
[
0
])
**
3
)
...
...
demos/demo_wf1.py
View file @
d349bf74
...
@@ -49,8 +49,8 @@ if __name__ == "__main__":
...
@@ -49,8 +49,8 @@ if __name__ == "__main__":
#shape = [1024, 1024]
#shape = [1024, 1024]
#x_space = rg_space(shape)
#x_space = rg_space(shape)
#y_space = point_space(1280*1280)
#y_space = point_space(1280*1280)
x_space
=
hp_s
pace
(
32
)
x_space
=
HpS
pace
(
32
)
#x_space =
gl_s
pace(800)
#x_space =
GlS
pace(800)
k_space
=
x_space
.
get_codomain
()
# get conjugate space
k_space
=
x_space
.
get_codomain
()
# get conjugate space
...
...
demos/demo_wf2.py
View file @
d349bf74
...
@@ -55,7 +55,8 @@ from nifty.operators.nifty_minimization import steepest_descent_new
...
@@ -55,7 +55,8 @@ from nifty.operators.nifty_minimization import steepest_descent_new
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
# some signal space; e.g., a two-dimensional regular grid
# some signal space; e.g., a two-dimensional regular grid
x_space
=
rg_space
([
256
,
256
])
# define signal space
x_space
=
RgSpace
([
256
,
256
])
# define
# signal space
k_space
=
x_space
.
get_codomain
()
# get conjugate space
k_space
=
x_space
.
get_codomain
()
# get conjugate space
...
...
demos/demo_wf3.py
View file @
d349bf74
...
@@ -39,7 +39,8 @@ if __name__ == "__main__":
...
@@ -39,7 +39,8 @@ if __name__ == "__main__":
# some signal space; e.g., a one-dimensional regular grid
# some signal space; e.g., a one-dimensional regular grid
x_space
=
rg_space
([
128
,])
# define signal space
x_space
=
RgSpace
([
128
,])
#
# define signal space
k_space
=
x_space
.
get_codomain
()
# get conjugate space
k_space
=
x_space
.
get_codomain
()
# get conjugate space
...
...
lm/__init__.py
View file @
d349bf74
...
@@ -38,7 +38,8 @@ except(ImportError):
...
@@ -38,7 +38,8 @@ except(ImportError):
"INFO: neither libsharp_wrapper_gl nor healpy available."
)
"INFO: neither libsharp_wrapper_gl nor healpy available."
)
pass
## import nothing
pass
## import nothing
else
:
else
:
from
nifty_lm
import
lm_space
,
hp_space
## import lm & hp
from
lm_space
import
LmSpace
## import lm & hp
from
hp_space
import
HpSpace
## TODO: change about
## TODO: change about
else
:
else
:
try
:
try
:
...
@@ -48,9 +49,12 @@ else:
...
@@ -48,9 +49,12 @@ else:
about
.
_errors
.
cprint
(
about
.
_errors
.
cprint
(
"ERROR: installed healpy version is older than 1.8.1!"
))
"ERROR: installed healpy version is older than 1.8.1!"
))
except
(
ImportError
):
except
(
ImportError
):
from
nifty_lm
import
lm_space
,
gl_space
## import lm & gl
from
gl_space
import
GlSpace
## import lm & gl
from
lm_space
import
LmSpace
else
:
else
:
from
nifty_lm
import
lm_space
,
gl_space
,
hp_space
##import all
from
gl_space
import
GlSpace
##import all
from
lm_space
import
LmSpace
from
hp_space
import
HpSpace
from
nifty.lm.nifty_power_conversion_lm
import
power_backward_conversion_lm
,
\
from
nifty.lm.nifty_power_conversion_lm
import
power_backward_conversion_lm
,
\
power_forward_conversion_lm
power_forward_conversion_lm
...
...
lm/gl_space.py
0 → 100644
View file @
d349bf74
This diff is collapsed.
Click to expand it.
lm/hp_space.py
0 → 100644
View file @
d349bf74
This diff is collapsed.
Click to expand it.
lm/
nifty_lm
.py
→
lm/
lm_space
.py
View file @
d349bf74
This diff is collapsed.
Click to expand it.
power/power_space.py
View file @
d349bf74
...
@@ -7,7 +7,7 @@ from nifty.nifty_paradict import power_space_paradict
...
@@ -7,7 +7,7 @@ from nifty.nifty_paradict import power_space_paradict
class
PowerSpace
(
Space
):
class
PowerSpace
(
Space
):
def
__init__
(
self
,
dtype
=
np
.
dtype
(
'float'
),
distribution_strategy
,
def
__init__
(
self
,
dtype
=
np
.
dtype
(
'float'
),
distribution_strategy
=
'fftw'
,
log
=
False
,
nbin
=
None
,
binbounds
=
None
):
log
=
False
,
nbin
=
None
,
binbounds
=
None
):
self
.
dtype
=
np
.
dtype
(
dtype
)
self
.
dtype
=
np
.
dtype
(
dtype
)
self
.
paradict
=
power_space_paradict
(
self
.
paradict
=
power_space_paradict
(
...
...
power/rg_power_space.py
View file @
d349bf74
...
@@ -4,7 +4,7 @@ import numpy as np
...
@@ -4,7 +4,7 @@ import numpy as np
from
nifty.power
import
PowerSpace
from
nifty.power
import
PowerSpace
from
nifty.nifty_paradict
import
rg_power_space_paradict
from
nifty.nifty_paradict
import
rg_power_space_paradict
from
nifty.power.power_index_factory
import
RGPowerIndexFactory
#
from nifty.power.power_index_factory import RGPowerIndexFactory
class
RGPowerSpace
(
PowerSpace
):
class
RGPowerSpace
(
PowerSpace
):
...
@@ -16,10 +16,10 @@ class RGPowerSpace(PowerSpace):
...
@@ -16,10 +16,10 @@ class RGPowerSpace(PowerSpace):
shape
=
shape
,
shape
=
shape
,
dgrid
=
dgrid
,
dgrid
=
dgrid
,
zerocentered
=
zerocentered
,
zerocentered
=
zerocentered
,
distribution_strategy
=
distribution_strategy
distribution_strategy
=
distribution_strategy
,
log
=
log
,
log
=
log
,
nbin
=
nbin
,
nbin
=
nbin
,
binbounds
=
binbounds
)
binbounds
=
binbounds
)
self
.
power_indices
=
RGPowerIndexFactory
.
get_power_indices
(
#
self.power_indices = RGPowerIndexFactory.get_power_indices(
**
self
.
paradict
.
parameters
)
#
**self.paradict.parameters)
rg/__init__.py
View file @
d349bf74
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
## along with this program. If not, see <http://www.gnu.org/licenses/>.
## along with this program. If not, see <http://www.gnu.org/licenses/>.
from
__future__
import
division
from
__future__
import
division
from
nifty_rg
import
rg_s
pace
,
\
from
nifty_rg
import
RgS
pace
,
\
utilities
utilities
from
nifty_power_conversion_rg
import
power_backward_conversion_rg
,
\
from
nifty_power_conversion_rg
import
power_backward_conversion_rg
,
\
power_forward_conversion_rg
power_forward_conversion_rg
...
...
rg/nifty_rg.py
View file @
d349bf74
...
@@ -59,7 +59,7 @@ MPI = gdi[gc['mpi_module']]
...
@@ -59,7 +59,7 @@ MPI = gdi[gc['mpi_module']]
RG_DISTRIBUTION_STRATEGIES
=
DISTRIBUTION_STRATEGIES
[
'global'
]
RG_DISTRIBUTION_STRATEGIES
=
DISTRIBUTION_STRATEGIES
[
'global'
]
class
rg_s
pace
(
Space
):
class
RgS
pace
(
Space
):
"""
"""
.. _____ _______
.. _____ _______
.. / __/ / _ /
.. / __/ / _ /
...
@@ -241,7 +241,7 @@ class rg_space(Space):
...
@@ -241,7 +241,7 @@ class rg_space(Space):
return
tuple
(
sorted
(
temp
))
return
tuple
(
sorted
(
temp
))
def
copy
(
self
):
def
copy
(
self
):
return
rg_s
pace
(
shape
=
self
.
paradict
[
'shape'
],
return
RgS
pace
(
shape
=
self
.
paradict
[
'shape'
],
complexity
=
self
.
paradict
[
'complexity'
],
complexity
=
self
.
paradict
[
'complexity'
],
zerocenter
=
self
.
paradict
[
'zerocenter'
],
zerocenter
=
self
.
paradict
[
'zerocenter'
],
distances
=
self
.
distances
,
distances
=
self
.
distances
,
...
@@ -353,7 +353,7 @@ class rg_space(Space):
...
@@ -353,7 +353,7 @@ class rg_space(Space):
if
codomain
is
None
:
if
codomain
is
None
:
return
False
return
False
if
not
isinstance
(
codomain
,
rg_s
pace
):
if
not
isinstance
(
codomain
,
RgS
pace
):
raise
TypeError
(
about
.
_errors
.
cstring
(
raise
TypeError
(
about
.
_errors
.
cstring
(
"ERROR: The given codomain must be a nifty rg_space."
))
"ERROR: The given codomain must be a nifty rg_space."
))
...
@@ -461,7 +461,7 @@ class rg_space(Space):
...
@@ -461,7 +461,7 @@ class rg_space(Space):
complexity
=
{
0
:
1
,
1
:
0
,
2
:
2
}[
self
.
paradict
[
'complexity'
]]
complexity
=
{
0
:
1
,
1
:
0
,
2
:
2
}[
self
.
paradict
[
'complexity'
]]
harmonic
=
bool
(
not
self
.
harmonic
)
harmonic
=
bool
(
not
self
.
harmonic
)
new_space
=
rg_s
pace
(
shape
,
new_space
=
RgS
pace
(
shape
,
zerocenter
=
cozerocenter
,
zerocenter
=
cozerocenter
,
complexity
=
complexity
,
complexity
=
complexity
,
distances
=
distances
,
distances
=
distances
,
...
@@ -541,7 +541,7 @@ class rg_space(Space):
...
@@ -541,7 +541,7 @@ class rg_space(Space):
# Case 1: uniform distribution over {-1,+1}/{1,i,-1,-i}
# Case 1: uniform distribution over {-1,+1}/{1,i,-1,-i}
if
arg
[
'random'
]
==
'pm1'
and
not
hermitianizeQ
:
if
arg
[
'random'
]
==
'pm1'
and
not
hermitianizeQ
:
sample
=
super
(
rg_s
pace
,
self
).
get_random_values
(
**
arg
)
sample
=
super
(
RgS
pace
,
self
).
get_random_values
(
**
arg
)
elif
arg
[
'random'
]
==
'pm1'
and
hermitianizeQ
:
elif
arg
[
'random'
]
==
'pm1'
and
hermitianizeQ
:
sample
=
self
.
get_random_values
(
random
=
'uni'
,
vmin
=-
1
,
vmax
=
1
)
sample
=
self
.
get_random_values
(
random
=
'uni'
,
vmin
=-
1
,
vmax
=
1
)
...
@@ -579,14 +579,14 @@ class rg_space(Space):
...
@@ -579,14 +579,14 @@ class rg_space(Space):
# Case 2: normal distribution with zero-mean and a given standard
# Case 2: normal distribution with zero-mean and a given standard
# deviation or variance
# deviation or variance
elif
arg
[
'random'
]
==
'gau'
:
elif
arg
[
'random'
]
==
'gau'
:
sample
=
super
(
rg_s
pace
,
self
).
get_random_values
(
**
arg
)
sample
=
super
(
RgS
pace
,
self
).
get_random_values
(
**
arg
)
if
hermitianizeQ
:
if
hermitianizeQ
:
sample
=
utilities
.
hermitianize_gaussian
(
sample
)
sample
=
utilities
.
hermitianize_gaussian
(
sample
)
# Case 3: uniform distribution
# Case 3: uniform distribution
elif
arg
[
'random'
]
==
"uni"
and
not
hermitianizeQ
:
elif
arg
[
'random'
]
==
"uni"
and
not
hermitianizeQ
:
sample
=
super
(
rg_s
pace
,
self
).
get_random_values
(
**
arg
)
sample
=
super
(
RgS
pace
,
self
).
get_random_values
(
**
arg
)
elif
arg
[
'random'
]
==
"uni"
and
hermitianizeQ
:
elif
arg
[
'random'
]
==
"uni"
and
hermitianizeQ
:
# For a hermitian uniform sample, generate a gaussian one
# For a hermitian uniform sample, generate a gaussian one
...
@@ -1614,6 +1614,6 @@ class rg_space(Space):
...
@@ -1614,6 +1614,6 @@ class rg_space(Space):
fig
.
canvas
.
draw
()
fig
.
canvas
.
draw
()
def
__repr__
(
self
):
def
__repr__
(
self
):
string
=
super
(
rg_s
pace
,
self
).
__repr__
()
string
=
super
(
RgS
pace
,
self
).
__repr__
()
string
+=
repr
(
self
.
fft_machine
)
+
"
\n
"
string
+=
repr
(
self
.
fft_machine
)
+
"
\n
"
return
string
return
string
test/test_nifty_fft.py
View file @
d349bf74
...
@@ -6,7 +6,7 @@ import d2o
...
@@ -6,7 +6,7 @@ import d2o
class
TestFFTWTransform
(
unittest
.
TestCase
):
class
TestFFTWTransform
(
unittest
.
TestCase
):
def
test_comm
(
self
):
def
test_comm
(
self
):
x
=
nt
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
a
=
np
.
ones
((
8
,
8
))
b
=
d2o
.
distributed_data_object
(
a
)
b
=
d2o
.
distributed_data_object
(
a
)
b
.
comm
=
[
1
,
2
,
3
]
# change comm to something not supported
b
.
comm
=
[
1
,
2
,
3
]
# change comm to something not supported
...
@@ -14,14 +14,14 @@ class TestFFTWTransform(unittest.TestCase):
...
@@ -14,14 +14,14 @@ class TestFFTWTransform(unittest.TestCase):
x
.
fft_machine
.
transform
(
b
,
x
,
x
.
get_codomain
())
x
.
fft_machine
.
transform
(
b
,
x
,
x
.
get_codomain
())
def
test_shapemismatch
(
self
):
def
test_shapemismatch
(
self
):
x
=
nt
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
a
=
np
.
ones
((
8
,
8
))
b
=
x
.
cast
(
a
)
b
=
x
.
cast
(
a
)
with
self
.
assertRaises
(
ValueError
):
with
self
.
assertRaises
(
ValueError
):
x
.
fft_machine
.
transform
(
b
,
x
,
x
.
get_codomain
(),
axes
=
(
0
,
1
,
2
))
x
.
fft_machine
.
transform
(
b
,
x
,
x
.
get_codomain
(),
axes
=
(
0
,
1
,
2
))
def
test_local_ndarray
(
self
):
def
test_local_ndarray
(
self
):
x
=
nt
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
a
=
np
.
ones
((
8
,
8
))
self
.
assertTrue
(
self
.
assertTrue
(
np
.
allclose
(
np
.
allclose
(
...
@@ -31,7 +31,7 @@ class TestFFTWTransform(unittest.TestCase):
...
@@ -31,7 +31,7 @@ class TestFFTWTransform(unittest.TestCase):
)
)
def
test_local_notzero
(
self
):
def
test_local_notzero
(
self
):
x
=
nt
.
rg_s
pace
(
8
,
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
(
8
,
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
a
=
np
.
ones
((
8
,
8
))
b
=
x
.
cast
(
a
)
b
=
x
.
cast
(
a
)
self
.
assertTrue
(
self
.
assertTrue
(
...
@@ -42,7 +42,7 @@ class TestFFTWTransform(unittest.TestCase):
...
@@ -42,7 +42,7 @@ class TestFFTWTransform(unittest.TestCase):
)
)
def
test_not
(
self
):
def
test_not
(
self
):
x
=
nt
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
a
=
np
.
ones
((
8
,
8
))
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'not'
)
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'not'
)
self
.
assertTrue
(
self
.
assertTrue
(
...
@@ -53,7 +53,7 @@ class TestFFTWTransform(unittest.TestCase):
...
@@ -53,7 +53,7 @@ class TestFFTWTransform(unittest.TestCase):
)
)
def
test_mpi_axesnone
(
self
):
def
test_mpi_axesnone
(
self
):
x
=
nt
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
a
=
np
.
ones
((
8
,
8
))
b
=
x
.
cast
(
a
)
b
=
x
.
cast
(
a
)
self
.
assertTrue
(
self
.
assertTrue
(
...
@@ -64,7 +64,7 @@ class TestFFTWTransform(unittest.TestCase):
...
@@ -64,7 +64,7 @@ class TestFFTWTransform(unittest.TestCase):
)
)
def
test_mpi_axesnone_equal
(
self
):
def
test_mpi_axesnone_equal
(
self
):
x
=
nt
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
a
=
np
.
ones
((
8
,
8
))
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'equal'
)
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'equal'
)
self
.
assertTrue
(
self
.
assertTrue
(
...
@@ -75,7 +75,7 @@ class TestFFTWTransform(unittest.TestCase):
...
@@ -75,7 +75,7 @@ class TestFFTWTransform(unittest.TestCase):
)
)
def
test_mpi_axesall
(
self
):
def
test_mpi_axesall
(
self
):
x
=
nt
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
a
=
np
.
ones
((
8
,
8
))
b
=
x
.
cast
(
a
)
b
=
x
.
cast
(
a
)
self
.
assertTrue
(
self
.
assertTrue
(
...
@@ -86,7 +86,7 @@ class TestFFTWTransform(unittest.TestCase):
...
@@ -86,7 +86,7 @@ class TestFFTWTransform(unittest.TestCase):
)
)
def
test_mpi_axesall_equal
(
self
):
def
test_mpi_axesall_equal
(
self
):
x
=
nt
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
a
=
np
.
ones
((
8
,
8
))
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'equal'
)
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'equal'
)
self
.
assertTrue
(
self
.
assertTrue
(
...
@@ -97,7 +97,7 @@ class TestFFTWTransform(unittest.TestCase):
...
@@ -97,7 +97,7 @@ class TestFFTWTransform(unittest.TestCase):
)
)
def
test_mpi_zero
(
self
):
def
test_mpi_zero
(
self
):
x
=
nt
.
rg_s
pace
(
8
,
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
(
8
,
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
+
1j
*
np
.
zeros
((
8
,
8
))
a
=
np
.
ones
((
8
,
8
))
+
1j
*
np
.
zeros
((
8
,
8
))
b
=
x
.
cast
(
a
)
b
=
x
.
cast
(
a
)
self
.
assertTrue
(
self
.
assertTrue
(
...
@@ -108,7 +108,7 @@ class TestFFTWTransform(unittest.TestCase):
...
@@ -108,7 +108,7 @@ class TestFFTWTransform(unittest.TestCase):
)
)
def
test_mpi_zero_equal
(
self
):
def
test_mpi_zero_equal
(
self
):
x
=
nt
.
rg_s
pace
(
8
,
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
(
8
,
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
+
1j
*
np
.
zeros
((
8
,
8
))
a
=
np
.
ones
((
8
,
8
))
+
1j
*
np
.
zeros
((
8
,
8
))
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'equal'
)
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'equal'
)
self
.
assertTrue
(
self
.
assertTrue
(
...
@@ -119,7 +119,7 @@ class TestFFTWTransform(unittest.TestCase):
...
@@ -119,7 +119,7 @@ class TestFFTWTransform(unittest.TestCase):
)
)
def
test_mpi_zero_not
(
self
):
def
test_mpi_zero_not
(
self
):
x
=
nt
.
rg_s
pace
(
8
,
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
(
8
,
fft_module
=
'pyfftw'
)
a
=
np
.
ones
((
8
,
8
))
+
1j
*
np
.
zeros
((
8
,
8
))
a
=
np
.
ones
((
8
,
8
))
+
1j
*
np
.
zeros
((
8
,
8
))
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'not'
)
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'not'
)
self
.
assertTrue
(
self
.
assertTrue
(
...
...
test/test_nifty_field.py
View file @
d349bf74
...
@@ -11,12 +11,12 @@ import numpy as np
...
@@ -11,12 +11,12 @@ import numpy as np
from
d2o
import
distributed_data_object
from
d2o
import
distributed_data_object
from
nifty
import
s
pace
,
\
from
nifty
import
S
pace
,
\
point_space
,
\
point_space
rg_space
,
\
lm_s
pace
,
\
from
nifty.rg
import
RgS
pace
hp_space
,
\
gl_space
from
nifty.lm
import
*
from
nifty.field
import
Field
from
nifty.field
import
Field
...
@@ -95,7 +95,7 @@ for param in itertools.product([(1,), (4, 6), (5, 8)],
...
@@ -95,7 +95,7 @@ for param in itertools.product([(1,), (4, 6), (5, 8)],
[
False
],
[
False
],
DATAMODELS
[
'rg_space'
],
DATAMODELS
[
'rg_space'
],
fft_modules
):
fft_modules
):
space_list
+=
[[
rg_s
pace
(
shape
=
param
[
0
],
space_list
+=
[[
RgS
pace
(
shape
=
param
[
0
],
zerocenter
=
param
[
1
],
zerocenter
=
param
[
1
],
complexity
=
param
[
2
],
complexity
=
param
[
2
],
distances
=
param
[
3
],
distances
=
param
[
3
],
...
@@ -104,12 +104,12 @@ for param in itertools.product([(1,), (4, 6), (5, 8)],
...
@@ -104,12 +104,12 @@ for param in itertools.product([(1,), (4, 6), (5, 8)],
def
generate_space_with_size
(
name
,
num
):
def
generate_space_with_size
(
name
,
num
):
space_dict
=
{
'space'
:
s
pace
(),
space_dict
=
{
'space'
:
S
pace
(),
'point_space'
:
point_space
(
num
),
'point_space'
:
point_space
(
num
),
'rg_space'
:
rg_s
pace
((
num
,
num
)),
'rg_space'
:
RgS
pace
((
num
,
num
)),
'lm_space'
:
lm_s
pace
(
mmax
=
num
+
1
,
lmax
=
num
+
1
),
'lm_space'
:
LmS
pace
(
mmax
=
num
+
1
,
lmax
=
num
+
1
),
'hp_space'
:
hp_s
pace
(
num
),
'hp_space'
:
HpS
pace
(
num
),
'gl_space'
:
gl_s
pace
(
nlat
=
num
,
nlon
=
2
*
num
-
1
),
'gl_space'
:
GlS
pace
(
nlat
=
num
,
nlon
=
2
*
num
-
1
),
}
}
return
space_dict
[
name
]
return
space_dict
[
name
]
...
@@ -135,7 +135,7 @@ class Test_field_init(unittest.TestCase):
...
@@ -135,7 +135,7 @@ class Test_field_init(unittest.TestCase):
def
test_successfull_init_and_attributes
(
self
,
shape
,
zerocenter
,
def
test_successfull_init_and_attributes
(
self
,
shape
,
zerocenter
,
complexity
,
distances
,
harmonic
,
complexity
,
distances
,
harmonic
,
fft_module
,
datamodel
):
fft_module
,
datamodel
):
s
=
rg_s
pace
(
shape
=
shape
,
zerocenter
=
zerocenter
,
s
=
RgS
pace
(
shape
=
shape
,
zerocenter
=
zerocenter
,
complexity
=
complexity
,
distances
=
distances
,
complexity
=
complexity
,
distances
=
distances
,
harmonic
=
harmonic
,
fft_module
=
fft_module
)
harmonic
=
harmonic
,
fft_module
=
fft_module
)
f
=
Field
(
domain
=
(
s
,),
dtype
=
s
.
dtype
,
datamodel
=
datamodel
)
f
=
Field
(
domain
=
(
s
,),
dtype
=
s
.
dtype
,
datamodel
=
datamodel
)
...
@@ -171,10 +171,10 @@ class Test_field_multiple_rg_init(unittest.TestCase):
...
@@ -171,10 +171,10 @@ class Test_field_multiple_rg_init(unittest.TestCase):
def
test_multiple_space_init
(
self
,
shape
,
zerocenter
,
def
test_multiple_space_init
(
self
,
shape
,
zerocenter
,
complexity
,
distances
,
harmonic
,
complexity
,
distances
,
harmonic
,
fft_module
,
datamodel
):
fft_module
,
datamodel
):
s1
=
rg_s
pace
(
shape
=
shape
,
zerocenter
=
zerocenter
,
s1
=
RgS
pace
(
shape
=
shape
,
zerocenter
=
zerocenter
,
complexity
=
complexity
,
distances
=
distances
,
complexity
=
complexity
,
distances
=
distances
,
harmonic
=
harmonic
,
fft_module
=
fft_module
)
harmonic
=
harmonic
,
fft_module
=
fft_module
)
s2
=
rg_s
pace
(
shape
=
shape
,
zerocenter
=
zerocenter
,
s2
=
RgS
pace
(
shape
=
shape
,
zerocenter
=
zerocenter
,
complexity
=
complexity
,
distances
=
distances
,