Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NIFTy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
13
Merge Requests
13
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ift
NIFTy
Commits
a78e1e01
Commit
a78e1e01
authored
Jul 31, 2019
by
Philipp Arras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup and cosmetics in tests
parent
1c1a6b51
Pipeline
#52937
passed with stages
in 8 minutes and 9 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
26 additions
and
49 deletions
+26
-49
test/test_field.py
test/test_field.py
+2
-4
test/test_minimizers.py
test/test_minimizers.py
+0
-1
test/test_operators/test_convolution_operators.py
test/test_operators/test_convolution_operators.py
+2
-3
test/test_operators/test_jacobian.py
test/test_operators/test_jacobian.py
+3
-15
test/test_operators/test_nft.py
test/test_operators/test_nft.py
+1
-1
test/test_operators/test_representation.py
test/test_operators/test_representation.py
+8
-12
test/test_operators/test_simplification.py
test/test_operators/test_simplification.py
+0
-1
test/test_spaces/test_lm_space.py
test/test_spaces/test_lm_space.py
+4
-6
test/test_spaces/test_power_space.py
test/test_spaces/test_power_space.py
+3
-2
test/test_sugar.py
test/test_sugar.py
+3
-4
No files found.
test/test_field.py
View file @
a78e1e01
...
...
@@ -57,8 +57,6 @@ def test_power_synthesize_analyze(space1, space2):
fp1
=
ift
.
PS_field
(
p1
,
_spec1
)
p2
=
ift
.
PowerSpace
(
space2
)
fp2
=
ift
.
PS_field
(
p2
,
_spec2
)
outer
=
np
.
outer
(
fp1
.
to_global_data
(),
fp2
.
to_global_data
())
fp
=
ift
.
Field
.
from_global_data
((
p1
,
p2
),
outer
)
op1
=
ift
.
create_power_operator
((
space1
,
space2
),
_spec1
,
0
)
op2
=
ift
.
create_power_operator
((
space1
,
space2
),
_spec2
,
1
)
...
...
@@ -345,11 +343,11 @@ def test_funcs(num, dom, func):
@
pmp
(
'dtype'
,
[
np
.
float64
,
np
.
complex128
])
def
test_from_random
(
rtype
,
dtype
):
sp
=
ift
.
RGSpace
(
3
)
f
=
ift
.
Field
.
from_random
(
rtype
,
sp
,
dtype
=
dtype
)
ift
.
Field
.
from_random
(
rtype
,
sp
,
dtype
=
dtype
)
def
test_field_of_objects
():
arr
=
np
.
array
([
'x'
,
'y'
,
'z'
])
sp
=
ift
.
RGSpace
(
3
)
with
assert_raises
(
TypeError
):
f
=
ift
.
Field
.
from_global_data
(
sp
,
arr
)
ift
.
Field
.
from_global_data
(
sp
,
arr
)
test/test_minimizers.py
View file @
a78e1e01
...
...
@@ -77,7 +77,6 @@ def test_quadratic_minimization(minimizer, space):
@
pmp
(
'space'
,
spaces
)
def
test_WF_curvature
(
space
):
np
.
random
.
seed
(
42
)
starting_point
=
ift
.
Field
.
from_random
(
'normal'
,
domain
=
space
)
*
10
required_result
=
ift
.
full
(
space
,
1.
)
s
=
ift
.
Field
.
from_random
(
'uniform'
,
domain
=
space
)
+
0.5
...
...
test/test_operators/test_convolution_operators.py
View file @
a78e1e01
...
...
@@ -15,7 +15,7 @@
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
from
numpy.testing
import
assert_allclose
,
assert_equal
from
numpy.testing
import
assert_allclose
import
nifty5
as
ift
import
numpy
as
np
...
...
@@ -30,9 +30,8 @@ space = list2fixture([
def
test_const_func
(
space
):
ones
=
lambda
x
:
np
.
ones
(
x
.
shape
)
sig
=
ift
.
Field
.
from_random
(
'normal'
,
domain
=
space
)
fco_op
=
ift
.
FuncConvolutionOperator
(
space
,
ones
)
fco_op
=
ift
.
FuncConvolutionOperator
(
space
,
lambda
x
:
np
.
ones
(
x
.
shape
)
)
vals
=
fco_op
(
sig
).
to_global_data
()
vals
=
np
.
round
(
vals
,
decimals
=
5
)
assert
len
(
np
.
unique
(
vals
))
==
1
...
...
test/test_operators/test_jacobian.py
View file @
a78e1e01
...
...
@@ -33,19 +33,11 @@ space1 = space
seed
=
list2fixture
([
4
,
78
,
23
])
def
_make_linearization
(
type
,
space
,
seed
):
def
testBasics
(
space
,
seed
):
np
.
random
.
seed
(
seed
)
S
=
ift
.
ScalingOperator
(
1.
,
space
)
s
=
S
.
draw_sample
()
if
type
==
"Constant"
:
return
ift
.
Linearization
.
make_const
(
s
)
elif
type
==
"Variable"
:
return
ift
.
Linearization
.
make_var
(
s
)
raise
ValueError
(
'unknown type passed'
)
def
testBasics
(
space
,
seed
):
var
=
_make_linearization
(
"Variable"
,
space
,
seed
)
var
=
ift
.
Linearization
.
make_var
(
s
)
model
=
ift
.
ScalingOperator
(
6.
,
var
.
target
)
ift
.
extra
.
check_jacobian_consistency
(
model
,
var
.
val
)
...
...
@@ -55,11 +47,7 @@ def testBasics(space, seed):
def
testBinary
(
type1
,
type2
,
space
,
seed
):
dom1
=
ift
.
MultiDomain
.
make
({
's1'
:
space
})
dom2
=
ift
.
MultiDomain
.
make
({
's2'
:
space
})
# FIXME Remove this?
_make_linearization
(
type1
,
dom1
,
seed
)
_make_linearization
(
type2
,
dom2
,
seed
)
np
.
random
.
seed
(
seed
)
dom
=
ift
.
MultiDomain
.
union
((
dom1
,
dom2
))
select_s1
=
ift
.
ducktape
(
None
,
dom1
,
"s1"
)
select_s2
=
ift
.
ducktape
(
None
,
dom2
,
"s2"
)
...
...
test/test_operators/test_nft.py
View file @
a78e1e01
...
...
@@ -17,7 +17,7 @@
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
allclose
,
assert_
from
numpy.testing
import
assert_
import
nifty5
as
ift
...
...
test/test_operators/test_representation.py
View file @
a78e1e01
...
...
@@ -57,8 +57,8 @@ def testOperatorCombinations(sp, dtype):
b
=
ift
.
DiagonalOperator
(
ift
.
Field
.
from_random
(
"normal"
,
sp
,
dtype
=
dtype
))
_check_repr
(
ift
.
SandwichOperator
.
make
(
a
,
b
))
_check_repr
(
a
(
b
))
_check_repr
(
a
+
b
)
_check_repr
(
a
-
b
)
_check_repr
(
a
+
b
)
_check_repr
(
a
-
b
)
_check_repr
(
a
*
b
)
_check_repr
(
a
**
2
)
...
...
@@ -211,7 +211,6 @@ def testExpTransform(args, dtype):
((
ift
.
LogRGSpace
(
10
,
[
2.
],
[
1.
]),
ift
.
UnstructuredDomain
(
13
)),
0
),
((
ift
.
UnstructuredDomain
(
13
),
ift
.
LogRGSpace
(
17
,
[
3.
],
[.
7
])),
1
)])
def
testQHTOperator
(
args
):
dtype
=
np
.
float64
tgt
=
ift
.
DomainTuple
.
make
(
args
[
0
])
_check_repr
(
ift
.
QHTOperator
(
tgt
,
args
[
1
]))
...
...
@@ -225,14 +224,11 @@ def testRegridding(args):
_check_repr
(
ift
.
RegriddingOperator
(
*
args
))
@
pmp
(
'fdomain'
,
[
ift
.
DomainTuple
.
make
((
ift
.
RGSpace
(
(
3
,
5
,
4
)),
ift
.
RGSpace
((
16
,),
distances
=
(
7.
,))),),
ift
.
DomainTuple
.
make
(
ift
.
HPSpace
(
12
),)
],
)
@
pmp
(
'fdomain'
,
[
ift
.
DomainTuple
.
make
((
ift
.
RGSpace
(
(
3
,
5
,
4
)),
ift
.
RGSpace
((
16
,),
distances
=
(
7.
,))),),
ift
.
DomainTuple
.
make
(
ift
.
HPSpace
(
12
),)
])
@
pmp
(
'domain'
,
[
ift
.
DomainTuple
.
make
((
ift
.
RGSpace
((
2
,)),
ift
.
GLSpace
(
10
)),),
ift
.
DomainTuple
.
make
(
ift
.
RGSpace
((
10
,
12
),
distances
=
(
0.1
,
1.
)),)
...
...
@@ -251,5 +247,5 @@ def testValueInserter(sp, seed):
if
ss
==
1
:
ind
.
append
(
0
)
else
:
ind
.
append
(
np
.
random
.
randint
(
0
,
ss
-
1
))
ind
.
append
(
np
.
random
.
randint
(
0
,
ss
-
1
))
_check_repr
(
ift
.
ValueInserter
(
sp
,
ind
))
test/test_operators/test_simplification.py
View file @
a78e1e01
...
...
@@ -15,7 +15,6 @@
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import
pytest
from
numpy.testing
import
assert_allclose
,
assert_equal
import
nifty5
as
ift
...
...
test/test_spaces/test_lm_space.py
View file @
a78e1e01
...
...
@@ -66,8 +66,7 @@ def get_k_length_array_configs():
@
pmp
(
'attribute'
,
[
'lmax'
,
'mmax'
,
'size'
])
def
test_property_ret_type
(
attribute
):
l
=
ift
.
LMSpace
(
7
,
5
)
assert_
(
isinstance
(
getattr
(
l
,
attribute
),
int
))
assert_
(
isinstance
(
getattr
(
ift
.
LMSpace
(
7
,
5
),
attribute
),
int
))
@
pmp
(
'lmax, mmax, expected'
,
CONSTRUCTOR_CONFIGS
)
...
...
@@ -76,9 +75,8 @@ def test_constructor(lmax, mmax, expected):
with
assert_raises
(
expected
[
'error'
]):
ift
.
LMSpace
(
lmax
,
mmax
)
else
:
l
=
ift
.
LMSpace
(
lmax
,
mmax
)
for
key
,
value
in
expected
.
items
():
assert_equal
(
getattr
(
l
,
key
),
value
)
assert_equal
(
getattr
(
ift
.
LMSpace
(
lmax
,
mmax
)
,
key
),
value
)
def
test_dvol
():
...
...
@@ -87,5 +85,5 @@ def test_dvol():
@
pmp
(
'lmax, expected'
,
get_k_length_array_configs
())
def
test_k_length_array
(
lmax
,
expected
):
l
=
ift
.
LMSpace
(
lmax
)
assert_allclose
(
l
.
get_k_length_array
().
to_global_data
(),
expected
)
assert_allclose
(
ift
.
LMSpace
(
lmax
).
get_k_length_array
().
to_global_data
(),
expected
)
test/test_spaces/test_power_space.py
View file @
a78e1e01
...
...
@@ -17,11 +17,12 @@
from
itertools
import
chain
,
product
import
pytest
import
nifty5
as
ift
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
,
assert_allclose
,
assert_equal
,
assert_raises
import
nifty5
as
ift
pmp
=
pytest
.
mark
.
parametrize
HARMONIC_SPACES
=
[
...
...
test/test_sugar.py
View file @
a78e1e01
...
...
@@ -16,8 +16,7 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_allclose
,
assert_equal
,
assert_raises
from
numpy.testing
import
assert_equal
import
nifty5
as
ift
...
...
@@ -25,8 +24,8 @@ import nifty5 as ift
def
test_get_signal_variance
():
space
=
ift
.
RGSpace
(
3
)
hspace
=
space
.
get_default_codomain
()
s
pec1
=
lambda
x
:
np
.
ones_like
(
x
)
assert_equal
(
ift
.
get_signal_variance
(
spec1
,
hspace
)
,
3.
)
s
v
=
ift
.
get_signal_variance
(
lambda
x
:
np
.
ones_like
(
x
),
hspace
)
assert_equal
(
sv
,
3.
)
space
=
ift
.
RGSpace
(
3
,
distances
=
1.
)
hspace
=
space
.
get_default_codomain
()
...
...
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