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
On Thursday, 7th July from 1 to 3 pm there will be a maintenance with a short downtime of GitLab.
Open sidebar
ift
NIFTy
Commits
8ecae7a7
Commit
8ecae7a7
authored
Apr 21, 2017
by
Theo Steininger
Browse files
Updated tests.
parent
aa122818
Pipeline
#11624
passed with stage
in 10 minutes and 7 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
test/common.py
View file @
8ecae7a7
...
...
@@ -67,11 +67,12 @@ def expand(*args, **kwargs):
def
generate_spaces
():
spaces
=
[
RGSpace
(
4
),
PowerSpace
(
RGSpace
((
4
,
4
),
harmonic
=
True
)),
LMSpace
(
5
),
HPSpace
(
4
),
GLSpace
(
4
)]
LMSpace
(
5
),
HPSpace
(
4
)]
if
'pyHealpix'
in
di
:
spaces
.
append
(
GLSpace
(
4
))
return
spaces
def
generate_harmonic_spaces
():
spaces
=
[
RGSpace
(
4
),
LMSpace
(
5
)]
def
generate_harmonic_spaces
():
spaces
=
[
RGSpace
(
4
,
harmonic
=
True
),
LMSpace
(
5
)]
return
spaces
test/test_spaces/test_gl_space.py
View file @
8ecae7a7
...
...
@@ -46,7 +46,7 @@ CONSTRUCTOR_CONFIGS = [
def
get_weight_configs
():
np
.
random
.
seed
(
42
)
wgt
=
[
2.0943951
,
2.0943951
]
wgt
=
[
2.0943951
,
2.0943951
]
# for GLSpace(nlat=2, nlon=3)
weight_0
=
np
.
array
(
list
(
itertools
.
chain
.
from_iterable
(
itertools
.
repeat
(
x
,
3
)
for
x
in
wgt
)))
...
...
@@ -69,13 +69,22 @@ class GLSpaceInterfaceTests(unittest.TestCase):
@
expand
([[
'nlat'
,
int
],
[
'nlon'
,
int
]])
def
test_property_ret_type
(
self
,
attribute
,
expected_type
):
g
=
GLSpace
(
2
)
assert_
(
isinstance
(
getattr
(
g
,
attribute
),
expected_type
))
try
:
g
=
GLSpace
(
2
)
except
ImportError
:
raise
SkipTest
else
:
assert_
(
isinstance
(
getattr
(
g
,
attribute
),
expected_type
))
class
GLSpaceFunctionalityTests
(
unittest
.
TestCase
):
@
expand
(
CONSTRUCTOR_CONFIGS
)
def
test_constructor
(
self
,
nlat
,
nlon
,
dtype
,
expected
):
try
:
g
=
GLSpace
(
4
)
except
ImportError
:
raise
SkipTest
if
'error'
in
expected
:
with
assert_raises
(
expected
[
'error'
]):
GLSpace
(
nlat
,
nlon
,
dtype
)
...
...
@@ -86,6 +95,11 @@ class GLSpaceFunctionalityTests(unittest.TestCase):
@
expand
(
get_weight_configs
())
def
test_weight
(
self
,
x
,
power
,
axes
,
inplace
,
expected
):
try
:
g
=
GLSpace
(
4
)
except
ImportError
:
raise
SkipTest
if
'pyHealpix'
not
in
di
:
raise
SkipTest
else
:
...
...
test/test_spaces/test_hp_space.py
View file @
8ecae7a7
...
...
@@ -22,7 +22,6 @@ import numpy as np
from
numpy.testing
import
assert_
,
assert_equal
,
assert_raises
,
\
assert_almost_equal
from
nifty
import
HPSpace
from
nifty.config
import
dependency_injector
as
di
from
test.common
import
expand
# [nside, dtype, expected]
...
...
test/test_spaces/test_lm_space.py
View file @
8ecae7a7
...
...
@@ -50,6 +50,7 @@ CONSTRUCTOR_CONFIGS = [
}]
]
def
_distance_array_helper
(
index_arr
,
lmax
):
if
index_arr
<=
lmax
:
index_half
=
index_arr
...
...
@@ -64,6 +65,7 @@ def _distance_array_helper(index_arr, lmax):
return
index_half
-
m
*
(
2
*
lmax
+
1
-
m
)
//
2
def
get_distance_array_configs
():
da_0
=
[
_distance_array_helper
(
idx
,
5
)
for
idx
in
np
.
arange
(
36
)]
return
[[
5
,
None
,
da_0
]]
...
...
@@ -77,6 +79,7 @@ def get_weight_configs():
[
w_0_x
.
copy
(),
1
,
None
,
True
,
w_0_x
]
]
def
get_hermitian_configs
():
np
.
random
.
seed
(
42
)
h_0_res_real
=
np
.
random
.
rand
(
32
,
16
,
6
).
astype
(
np
.
complex128
)
...
...
@@ -86,6 +89,7 @@ def get_hermitian_configs():
[
h_0_x
,
h_0_res_real
,
h_0_res_imag
]
]
class
LMSpaceInterfaceTests
(
unittest
.
TestCase
):
@
expand
([[
'lmax'
,
int
],
[
'mmax'
,
int
],
...
...
test/test_spaces/test_power_space.py
View file @
8ecae7a7
...
...
@@ -24,7 +24,7 @@ import numpy as np
from
d2o
import
distributed_data_object
from
numpy.testing
import
assert_
,
assert_equal
,
assert_almost_equal
,
\
assert_raises
from
nifty
import
PowerSpace
,
RGSpace
,
LMSpace
,
Space
from
nifty
import
PowerSpace
,
RGSpace
,
Space
from
types
import
NoneType
from
test.common
import
expand
...
...
test/test_spaces/test_rg_space.py
View file @
8ecae7a7
...
...
@@ -218,7 +218,6 @@ def get_hermitian_configs():
]
class
RGSpaceInterfaceTests
(
unittest
.
TestCase
):
@
expand
([[
'distances'
,
tuple
],
[
'zerocenter'
,
tuple
]])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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