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,\
## optional submodule `rg`
try
:
from
rg
import
rg_s
pace
,
\
from
rg
import
RgS
pace
,
\
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
lm_s
pace
,
\
from
lm
import
LmS
pace
,
\
power_backward_conversion_lm
,
\
power_forward_conversion_lm
from
nifty_paradict
import
lm_space_paradict
try
:
from
lm
import
gl_s
pace
from
lm
import
GlS
pace
from
nifty_paradict
import
gl_space_paradict
except
(
ImportError
):
pass
try
:
from
lm
import
hp_s
pace
from
lm
import
HpS
pace
from
nifty_paradict
import
hp_space_paradict
except
(
ImportError
):
pass
...
...
demos/demo_excaliwir.py
View file @
d349bf74
...
...
@@ -256,7 +256,7 @@ class problem(object):
##-----------------------------------------------------------------------------
#
if
(
__name__
==
"__main__"
):
x
=
rg_s
pace
((
1280
),
zerocenter
=
True
)
x
=
RgS
pace
((
1280
),
zerocenter
=
True
)
p
=
problem
(
x
,
log
=
False
)
about
.
warnings
.
off
()
## pl.close("all")
...
...
demos/demo_faraday.py
View file @
d349bf74
...
...
@@ -48,7 +48,8 @@ about.infos.off()
##-----------------------------------------------------------------------------
# (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):
m4
.
plot
(
title
=
r
"angular quadrupole of $m$ on a Gauss-Legendre grid"
,
**
nicely
)
# (d) representation on regular grid
y_space
=
gl_s
pace
(
384
,
nlon
=
768
)
# auxiliary gl_space
z_space
=
rg_s
pace
([
768
,
384
],
dist
=
[
1
/
360
,
1
/
180
])
y_space
=
GlS
pace
(
384
,
nlon
=
768
)
# auxiliary gl_space
z_space
=
RgS
pace
([
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 @
d349bf74
...
...
@@ -9,7 +9,7 @@ if __name__ == "__main__":
shape
=
(
256
,
256
)
x_space
=
rg_s
pace
(
shape
)
x_space
=
RgS
pace
(
shape
)
k_space
=
x_space
.
get_codomain
()
power
=
lambda
k
:
42
/
((
1
+
k
*
shape
[
0
])
**
3
)
...
...
demos/demo_wf1.py
View file @
d349bf74
...
...
@@ -49,8 +49,8 @@ if __name__ == "__main__":
#shape = [1024, 1024]
#x_space = rg_space(shape)
#y_space = point_space(1280*1280)
x_space
=
hp_s
pace
(
32
)
#x_space =
gl_s
pace(800)
x_space
=
HpS
pace
(
32
)
#x_space =
GlS
pace(800)
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
if
__name__
==
"__main__"
:
# 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
...
...
demos/demo_wf3.py
View file @
d349bf74
...
...
@@ -39,7 +39,8 @@ if __name__ == "__main__":
# 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
...
...
lm/__init__.py
View file @
d349bf74
...
...
@@ -38,7 +38,8 @@ except(ImportError):
"INFO: neither libsharp_wrapper_gl nor healpy available."
)
pass
## import nothing
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
else
:
try
:
...
...
@@ -48,9 +49,12 @@ else:
about
.
_errors
.
cprint
(
"ERROR: installed healpy version is older than 1.8.1!"
))
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
:
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
,
\
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
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
):
self
.
dtype
=
np
.
dtype
(
dtype
)
self
.
paradict
=
power_space_paradict
(
...
...
power/rg_power_space.py
View file @
d349bf74
...
...
@@ -4,7 +4,7 @@ import numpy as np
from
nifty.power
import
PowerSpace
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
):
...
...
@@ -16,10 +16,10 @@ class RGPowerSpace(PowerSpace):
shape
=
shape
,
dgrid
=
dgrid
,
zerocentered
=
zerocentered
,
distribution_strategy
=
distribution_strategy
distribution_strategy
=
distribution_strategy
,
log
=
log
,
nbin
=
nbin
,
binbounds
=
binbounds
)
self
.
power_indices
=
RGPowerIndexFactory
.
get_power_indices
(
**
self
.
paradict
.
parameters
)
#
self.power_indices = RGPowerIndexFactory.get_power_indices(
#
**self.paradict.parameters)
rg/__init__.py
View file @
d349bf74
...
...
@@ -20,7 +20,7 @@
## along with this program. If not, see <http://www.gnu.org/licenses/>.
from
__future__
import
division
from
nifty_rg
import
rg_s
pace
,
\
from
nifty_rg
import
RgS
pace
,
\
utilities
from
nifty_power_conversion_rg
import
power_backward_conversion_rg
,
\
power_forward_conversion_rg
...
...
rg/nifty_rg.py
View file @
d349bf74
...
...
@@ -59,7 +59,7 @@ MPI = gdi[gc['mpi_module']]
RG_DISTRIBUTION_STRATEGIES
=
DISTRIBUTION_STRATEGIES
[
'global'
]
class
rg_s
pace
(
Space
):
class
RgS
pace
(
Space
):
"""
.. _____ _______
.. / __/ / _ /
...
...
@@ -241,7 +241,7 @@ class rg_space(Space):
return
tuple
(
sorted
(
temp
))
def
copy
(
self
):
return
rg_s
pace
(
shape
=
self
.
paradict
[
'shape'
],
return
RgS
pace
(
shape
=
self
.
paradict
[
'shape'
],
complexity
=
self
.
paradict
[
'complexity'
],
zerocenter
=
self
.
paradict
[
'zerocenter'
],
distances
=
self
.
distances
,
...
...
@@ -353,7 +353,7 @@ class rg_space(Space):
if
codomain
is
None
:
return
False
if
not
isinstance
(
codomain
,
rg_s
pace
):
if
not
isinstance
(
codomain
,
RgS
pace
):
raise
TypeError
(
about
.
_errors
.
cstring
(
"ERROR: The given codomain must be a nifty rg_space."
))
...
...
@@ -461,7 +461,7 @@ class rg_space(Space):
complexity
=
{
0
:
1
,
1
:
0
,
2
:
2
}[
self
.
paradict
[
'complexity'
]]
harmonic
=
bool
(
not
self
.
harmonic
)
new_space
=
rg_s
pace
(
shape
,
new_space
=
RgS
pace
(
shape
,
zerocenter
=
cozerocenter
,
complexity
=
complexity
,
distances
=
distances
,
...
...
@@ -541,7 +541,7 @@ class rg_space(Space):
# Case 1: uniform distribution over {-1,+1}/{1,i,-1,-i}
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
:
sample
=
self
.
get_random_values
(
random
=
'uni'
,
vmin
=-
1
,
vmax
=
1
)
...
...
@@ -579,14 +579,14 @@ class rg_space(Space):
# Case 2: normal distribution with zero-mean and a given standard
# deviation or variance
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
:
sample
=
utilities
.
hermitianize_gaussian
(
sample
)
# Case 3: uniform distribution
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
:
# For a hermitian uniform sample, generate a gaussian one
...
...
@@ -1614,6 +1614,6 @@ class rg_space(Space):
fig
.
canvas
.
draw
()
def
__repr__
(
self
):
string
=
super
(
rg_s
pace
,
self
).
__repr__
()
string
=
super
(
RgS
pace
,
self
).
__repr__
()
string
+=
repr
(
self
.
fft_machine
)
+
"
\n
"
return
string
test/test_nifty_fft.py
View file @
d349bf74
...
...
@@ -6,7 +6,7 @@ import d2o
class
TestFFTWTransform
(
unittest
.
TestCase
):
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
))
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
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
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
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
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
.
rg_s
pace
(
8
,
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
(
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
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
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
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
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
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
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
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
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
.
rg_s
pace
((
8
,
8
),
fft_module
=
'pyfftw'
)
x
=
nt
.
RgS
pace
((
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
.
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
))
b
=
x
.
cast
(
a
)
self
.
assertTrue
(
...
...
@@ -108,7 +108,7 @@ class TestFFTWTransform(unittest.TestCase):
)
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
))
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
.
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
))
b
=
d2o
.
distributed_data_object
(
a
,
distribution_strategy
=
'not'
)
self
.
assertTrue
(
...
...
test/test_nifty_field.py
View file @
d349bf74
...
...
@@ -11,12 +11,12 @@ import numpy as np
from
d2o
import
distributed_data_object
from
nifty
import
s
pace
,
\
point_space
,
\
rg_space
,
\
lm_s
pace
,
\
hp_space
,
\
gl_space
from
nifty
import
S
pace
,
\
point_space
from
nifty.rg
import
RgS
pace
from
nifty.lm
import
*
from
nifty.field
import
Field
...
...
@@ -95,7 +95,7 @@ for param in itertools.product([(1,), (4, 6), (5, 8)],
[
False
],
DATAMODELS
[
'rg_space'
],
fft_modules
):
space_list
+=
[[
rg_s
pace
(
shape
=
param
[
0
],
space_list
+=
[[
RgS
pace
(
shape
=
param
[
0
],
zerocenter
=
param
[
1
],
complexity
=
param
[
2
],
distances
=
param
[
3
],
...
...
@@ -104,12 +104,12 @@ for param in itertools.product([(1,), (4, 6), (5, 8)],
def
generate_space_with_size
(
name
,
num
):
space_dict
=
{
'space'
:
s
pace
(),
space_dict
=
{
'space'
:
S
pace
(),
'point_space'
:
point_space
(
num
),
'rg_space'
:
rg_s
pace
((
num
,
num
)),
'lm_space'
:
lm_s
pace
(
mmax
=
num
+
1
,
lmax
=
num
+
1
),
'hp_space'
:
hp_s
pace
(
num
),
'gl_space'
:
gl_s
pace
(
nlat
=
num
,
nlon
=
2
*
num
-
1
),
'rg_space'
:
RgS
pace
((
num
,
num
)),
'lm_space'
:
LmS
pace
(
mmax
=
num
+
1
,
lmax
=
num
+
1
),
'hp_space'
:
HpS
pace
(
num
),
'gl_space'
:
GlS
pace
(
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
=
rg_s
pace
(
shape
=
shape
,
zerocenter
=
zerocenter
,
s
=
RgS
pace
(
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
,
complexity
,
distances
,
harmonic
,
fft_module
,
datamodel
):
s1
=
rg_s
pace
(
shape
=
shape
,
zerocenter
=
zerocenter
,
s1
=
RgS
pace
(
shape
=
shape
,
zerocenter
=
zerocenter
,
complexity
=
complexity
,
distances
=
distances
,
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
,
harmonic
=
harmonic
,
fft_module
=
fft_module
)
f
=
Field
(
domain
=
(
s1
,
s2
),
dtype
=
s1
.
dtype
,
datamodel
=
datamodel
)
...
...
test/test_nifty_operators.py
View file @
d349bf74
...
...
@@ -9,8 +9,8 @@ import unittest
import
itertools
import
numpy
as
np
from
nifty
import
s
pace
,
\
rg_s
pace
,
\
from
nifty
import
S
pace
,
\
RgS
pace
,
\
Field
,
\
distributed_data_object
...
...
@@ -34,19 +34,19 @@ from nifty.lm.nifty_lm import LM_DISTRIBUTION_STRATEGIES,\
available
=
[]
try
:
from
nifty
import
lm_s
pace
from
nifty
import
LmS
pace
except
ImportError
:
pass
else
:
available
+=
[
'lm_space'
]
try
:
from
nifty
import
gl_s
pace
from
nifty
import
GlS
pace
except
ImportError
:
pass
else
:
available
+=
[
'gl_space'
]
try
:
from
nifty
import
hp_s
pace
from
nifty
import
HpS
pace
except
ImportError
:
pass
else
:
...
...
@@ -135,7 +135,7 @@ all_operators = ['operator', 'diagonal_operator', 'power_operator',
###############################################################################
def
generate_operator
(
name
):
x
=
rg_s
pace
((
8
,
8
))
x
=
RgS
pace
((
8
,
8
))
k
=
x
.
get_codomain
()
operator_dict
=
{
'operator'
:
operator
(
domain
=
x
),
'diagonal_operator'
:
diagonal_operator
(
domain
=
x
),
...
...
test/test_nifty_spaces.py
View file @
d349bf74
...
...
@@ -20,7 +20,7 @@ from nifty.nifty_core import POINT_DISTRIBUTION_STRATEGIES,\
from
nifty.rg.nifty_rg
import
RG_DISTRIBUTION_STRATEGIES
,
\
gc
as
RG_GC
,
\
rg_s
pace
RgS
pace
from
nifty.lm.nifty_lm
import
LM_DISTRIBUTION_STRATEGIES
,
\
GL_DISTRIBUTION_STRATEGIES
,
\
HP_DISTRIBUTION_STRATEGIES
...
...
@@ -32,19 +32,19 @@ from nifty.operators.nifty_operators import power_operator
available
=
[]
try
:
from
nifty
import
lm_s
pace
from
nifty
import
LmS
pace
except
ImportError
:
pass
else
:
available
+=
[
'lm_space'
]
try
:
from
nifty
import
gl_s
pace
from
nifty
import
GlS
pace
except
ImportError
:
pass
else
:
available
+=
[
'gl_space'
]
try
:
from
nifty
import
hp_s
pace
from
nifty
import
HpS
pace
except
ImportError
:
pass
else
:
...
...
@@ -169,14 +169,14 @@ fft_test_data = np.array(
def
generate_space
(
name
):
space_dict
=
{
'space'
:
space
(),
'point_space'
:
point_space
(
10
),
'rg_space'
:
rg_s
pace
((
8
,
8
)),
'rg_space'
:
RgS
pace
((
8
,
8
)),
}
if
'lm_space'
in
available
:
space_dict
[
'lm_space'
]
=
lm_s
pace
(
mmax
=
11
,
lmax
=
11
)
space_dict
[
'lm_space'
]
=
LmS
pace
(
mmax
=
11
,
lmax
=
11
)
if
'hp_space'
in
available
:
space_dict
[
'hp_space'
]
=
hp_s
pace
(
8
)
space_dict
[
'hp_space'
]
=
HpS
pace
(
8
)
if
'gl_space'
in
available
:
space_dict
[
'gl_space'
]
=
gl_s
pace
(
nlat
=
10
,
nlon
=
19
)
space_dict
[
'gl_space'
]
=
GlS
pace
(
nlat
=
10
,
nlon
=
19
)
return
space_dict
[
name
]
...
...
@@ -184,14 +184,14 @@ def generate_space(name):
def
generate_space_with_size
(
name
,
num
):
space_dict
=
{
'space'
:
space
(),
'point_space'
:
point_space
(
num
),
'rg_space'
:
rg_s
pace
((
num
,
num
)),
'rg_space'
:
RgS
pace
((
num
,
num
)),
}
if
'lm_space'
in
available
:
space_dict
[
'lm_space'
]
=
lm_s
pace
(
mmax
=
num
,
lmax
=
num
)
space_dict
[
'lm_space'
]
=
LmS
pace
(
mmax
=
num
,
lmax
=
num
)
if
'hp_space'
in
available
:
space_dict
[
'hp_space'
]
=
hp_s
pace
(
num
)
space_dict
[
'hp_space'
]
=
HpS
pace
(
num
)
if
'gl_space'
in
available
:
space_dict
[
'gl_space'
]
=
gl_s
pace
(
nlat
=
num
,
nlon
=
num
)
space_dict
[
'gl_space'
]
=
GlS
pace
(
nlat
=
num
,
nlon
=
num
)
return
space_dict
[
name
]
...
...
@@ -660,7 +660,7 @@ class Test_RG_Space(unittest.TestCase):
testcase_func_name
=
custom_name_func
)
def
test_successfull_init
(
self
,
shape
,
complexity
,
zerocenter
,
distances
,
harmonic
,
fft_module
):
x
=
rg_s
pace
(
shape
,
x
=
RgS
pace
(
shape
,
complexity
=
complexity
,
zerocenter
=
zerocenter
,
distances
=
distances
,
...
...
@@ -681,7 +681,7 @@ class Test_RG_Space(unittest.TestCase):
shape
=
(
10
,
10
)
zerocenter
=
True
complexity
=
2
x
=
rg_s
pace
(
shape
,
zerocenter
=
zerocenter
,
complexity
=
complexity
)
x
=
RgS
pace
(
shape
,
zerocenter
=
zerocenter
,
complexity
=
complexity
)
assert_equal
(
x
.
para
,
np
.
array
([
10
,
10
,
2
,
1
,
1
]))
new_para
=
np
.
array
([
6
,
6
,
1
,
0
,
1
])
...
...
@@ -691,11 +691,11 @@ class Test_RG_Space(unittest.TestCase):
###############################################################################
def
test_init_fail
(
self
):
assert_raises
(
ValueError
,
lambda
:
rg_s
pace
((
-
3
,
10
)))
assert_raises
(
ValueError
,
lambda
:
rg_s
pace
((
10
,
10
),
complexity
=
3
))
assert_raises
(
ValueError
,
lambda
:
rg_s
pace
((
10
,
10
),
assert_raises
(
ValueError
,
lambda
:
RgS
pace
((
-
3
,
10
)))
assert_raises
(
ValueError
,
lambda
:
RgS
pace
((
10
,
10
),
complexity
=
3
))
assert_raises
(
ValueError
,
lambda
:
RgS
pace
((
10
,
10
),
distances
=
[
1
,
1
,
1
]))
assert_raises
(
ValueError
,
lambda
:
rg_s
pace
((
10
,
10
),
assert_raises
(
ValueError
,
lambda
:
RgS
pace
((
10
,
10
),
zerocenter
=
[
1
,
1
,
1
]))
###############################################################################
...
...
@@ -714,7 +714,7 @@ class Test_RG_Space(unittest.TestCase):
@
parameterized
.
expand
([],
testcase_func_name
=
custom_name_func
)
def
test_enforce_power
(
self
):
shape
=
(
6
,
6
)
x
=
rg_s
pace
(
shape
)
x
=
RgS
pace
(
shape
)
assert_equal
(
x
.
enforce_power
(
2
),
np
.
array
([
2.
,
2.
,
2.
,
2.
,
2.
,
2.
,
2.
,
2.
,
2.
,
2.
]))
...
...
@@ -734,7 +734,7 @@ class Test_RG_Space(unittest.TestCase):
testcase_func_name
=
custom_name_func
)
def
test_get_check_codomain
(
self
,
complexity
,
distances
,
harmonic
):
shape
=
(
6
,
6
)
x
=
rg_s
pace
(
shape
,
complexity
=
complexity
,
distances
=
distances
,
x
=
RgS
pace
(
shape
,
complexity
=
complexity
,
distances
=
distances
,
harmonic
=
harmonic
)
y
=
x
.
get_codomain
()
assert
(
x
.
check_codomain
(
y
))
...
...
@@ -748,7 +748,7 @@ class Test_RG_Space(unittest.TestCase):
# #DATAMODELS['rg_space']),
# testcase_func_name=custom_name_func)
# def test_get_random_values(self, harmonic, datamodel):
# x =
rg_s
pace((4, 4), complexity=1, harmonic=harmonic,
# x =
RgS
pace((4, 4), complexity=1, harmonic=harmonic,
# datamodel=datamodel)
#
# # pm1
...
...
@@ -778,7 +778,7 @@ class Test_RG_Space(unittest.TestCase):
def
test_calc_dot
(
self
):
shape
=
(
8
,
8
)
a
=
np
.
arange
(
np
.
prod
(
shape
)).
reshape
(
shape
)
x
=
rg_s
pace
(
shape
)
x
=
RgS
pace
(
shape
)
assert_equal
(
x
.
calc_dot
(
a
,
a
),
85344
)
assert_equal
(
x
.
calc_dot
(
a
,
1
),
2016
)
assert_equal
(
x
.
calc_dot
(
1
,
a
),
2016
)
...
...
@@ -792,7 +792,7 @@ class Test_RG_Space(unittest.TestCase):
data
=
fft_test_data
.
copy
()
shape
=
data
.
shape
x
=
rg_s
pace
(
shape
,
complexity
=
complexity
)
x
=
RgS
pace
(
shape
,
complexity
=
complexity
)
data
=
fft_test_data
.
copy
()
data
=
x
.
cast
(
data
)
check_equality
(
x
,
data
,
x
.
calc_transform
(
x
.
calc_transform
(
data
)))
...
...
@@ -806,7 +806,7 @@ class Test_RG_Space(unittest.TestCase):
data
=
fft_test_data
.
copy
()
shape
=
data
.
shape
x
=
rg_s
pace
(
shape
,
complexity
=
2
,
zerocenter
=
False
,
x
=
RgS
pace
(
shape
,
complexity
=
2
,
zerocenter
=
False
,
fft_module
=
fft_module
)
casted_data
=
x
.
cast
(
data
)
assert
(
check_almost_equality
(
x
,
x
.
calc_transform
(
casted_data
),
...
...
@@ -829,7 +829,7 @@ class Test_RG_Space(unittest.TestCase):