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
10
Issues
10
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
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
f5118b0b
Commit
f5118b0b
authored
Nov 12, 2019
by
Philipp Haim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Checkout modified tests
parent
87e34527
Pipeline
#63550
passed with stages
in 6 minutes and 54 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
61 deletions
+24
-61
test/test_operators/test_jacobian.py
test/test_operators/test_jacobian.py
+22
-24
test/test_operators/test_representation.py
test/test_operators/test_representation.py
+0
-35
test/test_operators/test_value_inserter.py
test/test_operators/test_value_inserter.py
+2
-2
No files found.
test/test_operators/test_jacobian.py
View file @
f5118b0b
...
...
@@ -17,7 +17,6 @@
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
import
nifty5
as
ift
...
...
@@ -29,6 +28,11 @@ space = list2fixture([
ift
.
RGSpace
(
64
,
distances
=
.
789
),
ift
.
RGSpace
([
32
,
32
],
distances
=
.
789
)
])
_h_RG_spaces
=
[
ift
.
RGSpace
(
7
,
distances
=
0.2
,
harmonic
=
True
),
ift
.
RGSpace
((
12
,
46
),
distances
=
(.
2
,
.
3
),
harmonic
=
True
)
]
_h_spaces
=
_h_RG_spaces
+
[
ift
.
LMSpace
(
17
)]
space1
=
space
seed
=
list2fixture
([
4
,
78
,
23
])
...
...
@@ -85,29 +89,6 @@ def testBinary(type1, type2, space, seed):
ift
.
extra
.
check_jacobian_consistency
(
model
,
pos
,
ntries
=
20
)
def
testModelLibrary
(
space
,
seed
):
# Tests amplitude model and coorelated field model
np
.
random
.
seed
(
seed
)
domain
=
ift
.
PowerSpace
(
space
.
get_default_codomain
())
model
=
ift
.
SLAmplitude
(
target
=
domain
,
n_pix
=
4
,
a
=
.
5
,
k0
=
2
,
sm
=
3
,
sv
=
1.5
,
im
=
1.75
,
iv
=
1.3
)
assert_
(
isinstance
(
model
,
ift
.
Operator
))
S
=
ift
.
ScalingOperator
(
1.
,
model
.
domain
)
pos
=
S
.
draw_sample
()
ift
.
extra
.
check_jacobian_consistency
(
model
,
pos
,
ntries
=
20
)
model2
=
ift
.
CorrelatedField
(
space
,
model
)
S
=
ift
.
ScalingOperator
(
1.
,
model2
.
domain
)
pos
=
S
.
draw_sample
()
ift
.
extra
.
check_jacobian_consistency
(
model2
,
pos
,
ntries
=
20
)
domtup
=
ift
.
DomainTuple
.
make
((
space
,
space
))
model3
=
ift
.
MfCorrelatedField
(
domtup
,
[
model
,
model
])
S
=
ift
.
ScalingOperator
(
1.
,
model3
.
domain
)
pos
=
S
.
draw_sample
()
ift
.
extra
.
check_jacobian_consistency
(
model3
,
pos
,
ntries
=
20
)
def
testPointModel
(
space
,
seed
):
S
=
ift
.
ScalingOperator
(
1.
,
space
)
pos
=
S
.
draw_sample
()
...
...
@@ -163,3 +144,20 @@ def testDynamicModel(target, causal, minimum_phase, seed):
# FIXME I dont know why smaller tol fails for 3D example
ift
.
extra
.
check_jacobian_consistency
(
model
,
pos
,
tol
=
1e-5
,
ntries
=
20
)
@
pmp
(
'h_space'
,
_h_spaces
)
@
pmp
(
'specialbinbounds'
,
[
True
,
False
])
@
pmp
(
'logarithmic'
,
[
True
,
False
])
@
pmp
(
'nbin'
,
[
3
,
None
])
def
testNormalization
(
h_space
,
specialbinbounds
,
logarithmic
,
nbin
):
if
not
specialbinbounds
and
(
not
logarithmic
or
nbin
is
not
None
):
return
if
specialbinbounds
:
binbounds
=
ift
.
PowerSpace
.
useful_binbounds
(
h_space
,
logarithmic
,
nbin
)
else
:
binbounds
=
None
dom
=
ift
.
PowerSpace
(
h_space
,
binbounds
)
op
=
ift
.
library
.
correlated_fields
.
_Normalization
(
dom
)
pos
=
0.1
*
ift
.
from_random
(
'normal'
,
op
.
domain
)
ift
.
extra
.
check_jacobian_consistency
(
op
,
pos
)
test/test_operators/test_representation.py
View file @
f5118b0b
...
...
@@ -71,15 +71,6 @@ def testLinearInterpolator():
_check_repr
(
ift
.
LinearInterpolator
(
sp
,
pos
))
@
pmp
(
'args'
,
[(
ift
.
RGSpace
(
10
,
harmonic
=
True
),
4
,
0
),
(
ift
.
RGSpace
(
(
24
,
31
),
distances
=
(
0.4
,
2.34
),
harmonic
=
True
),
3
,
0
),
(
ift
.
LMSpace
(
4
),
10
,
0
)])
def
testSlopeOperator
(
args
,
dtype
):
tmp
=
ift
.
ExpTransform
(
ift
.
PowerSpace
(
args
[
0
]),
args
[
1
],
args
[
2
])
tgt
=
tmp
.
domain
[
0
]
_check_repr
(
ift
.
SlopeOperator
(
tgt
))
@
pmp
(
'sp'
,
_h_spaces
+
_p_spaces
+
_pow_spaces
)
def
testOperatorAdaptor
(
sp
,
dtype
):
op
=
ift
.
DiagonalOperator
(
ift
.
Field
.
from_random
(
"normal"
,
sp
,
dtype
=
dtype
))
...
...
@@ -179,13 +170,6 @@ def testDomainTupleFieldInserter():
_check_repr
(
ift
.
DomainTupleFieldInserter
(
target
,
1
,
(
5
,)))
@
pmp
(
'space'
,
[
0
,
2
])
def
testSymmetrizingOperator
(
space
,
dtype
):
dom
=
(
ift
.
LogRGSpace
(
10
,
[
2.
],
[
1.
]),
ift
.
UnstructuredDomain
(
13
),
ift
.
LogRGSpace
((
5
,
27
),
[
1.
,
2.7
],
[
0.
,
4.
]),
ift
.
HPSpace
(
4
))
_check_repr
(
ift
.
SymmetrizingOperator
(
dom
,
space
))
@
pmp
(
'space'
,
[
0
,
2
])
@
pmp
(
'factor'
,
[
1
,
2
,
2.7
])
@
pmp
(
'central'
,
[
False
,
True
])
...
...
@@ -196,25 +180,6 @@ def testZeroPadder(space, factor, dtype, central):
_check_repr
(
ift
.
FieldZeroPadder
(
dom
,
newshape
,
space
,
central
))
@
pmp
(
'args'
,
[(
ift
.
RGSpace
(
10
,
harmonic
=
True
),
4
,
0
),
(
ift
.
RGSpace
(
(
24
,
31
),
distances
=
(
0.4
,
2.34
),
harmonic
=
True
),
(
4
,
3
),
0
),
((
ift
.
HPSpace
(
4
),
ift
.
RGSpace
(
27
,
distances
=
0.3
,
harmonic
=
True
)),
(
10
,),
1
),
(
ift
.
PowerSpace
(
ift
.
RGSpace
(
10
,
distances
=
0.3
,
harmonic
=
True
)),
6
,
0
)])
def
testExpTransform
(
args
,
dtype
):
_check_repr
(
ift
.
ExpTransform
(
args
[
0
],
args
[
1
],
args
[
2
]))
@
pmp
(
'args'
,
[(
ift
.
LogRGSpace
([
10
,
17
],
[
2.
,
3.
],
[
1.
,
0.
]),
0
),
((
ift
.
LogRGSpace
(
10
,
[
2.
],
[
1.
]),
ift
.
UnstructuredDomain
(
13
)),
0
),
((
ift
.
UnstructuredDomain
(
13
),
ift
.
LogRGSpace
(
17
,
[
3.
],
[.
7
])),
1
)])
def
testQHTOperator
(
args
):
tgt
=
ift
.
DomainTuple
.
make
(
args
[
0
])
_check_repr
(
ift
.
QHTOperator
(
tgt
,
args
[
1
]))
@
pmp
(
'args'
,
[[
ift
.
RGSpace
(
(
13
,
52
,
40
)),
(
4
,
6
,
25
),
None
],
[
ift
.
RGSpace
(
(
128
,
128
)),
(
45
,
48
),
0
],
[
ift
.
RGSpace
(
13
),
(
7
,),
None
],
[
...
...
test/test_operators/test_value_inserter.py
View file @
f5118b0b
...
...
@@ -34,8 +34,8 @@ def test_value_inserter(sp, seed):
np
.
random
.
seed
(
seed
)
ind
=
tuple
([
np
.
random
.
randint
(
0
,
ss
-
1
)
for
ss
in
sp
.
shape
])
op
=
ift
.
ValueInserter
(
sp
,
ind
)
f
=
ift
.
from_random
(
'normal'
,
ift
.
UnstructuredDomain
((
1
,))
)
inp
=
f
.
to_global_data
()
[
0
]
f
=
ift
.
from_random
(
'normal'
,
op
.
domain
)
inp
=
f
.
to_global_data
()
ret
=
op
(
f
).
to_global_data
()
assert_
(
ret
[
ind
]
==
inp
)
assert_
(
np
.
sum
(
ret
)
==
inp
)
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