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
bfd57f63
Commit
bfd57f63
authored
Jul 20, 2018
by
Martin Reinecke
Browse files
Merge branch '16-add-operator-tests' into 'NIFTy_5'
cosmetics Closes
#16
See merge request ift/nifty-dev!63
parents
2cc75057
2924e62b
Changes
5
Hide whitespace changes
Inline
Side-by-side
demos/bernoulli_demo.py
View file @
bfd57f63
...
...
@@ -91,4 +91,5 @@ if __name__ == '__main__':
ift
.
plot
(
reconstruction
,
title
=
'reconstruction'
)
ift
.
plot
(
GR
.
adjoint_times
(
data
),
title
=
'data'
)
ift
.
plot
(
sky
.
at
(
mock_position
).
value
,
title
=
'truth'
)
ift
.
plot_finish
(
nx
=
3
,
xsize
=
16
,
ysize
=
5
,
title
=
"results"
,
name
=
"bernoulli.png"
)
ift
.
plot_finish
(
nx
=
3
,
xsize
=
16
,
ysize
=
5
,
title
=
"results"
,
name
=
"bernoulli.png"
)
demos/getting_started_3.py
View file @
bfd57f63
...
...
@@ -115,4 +115,5 @@ if __name__ == '__main__':
powers
=
[
A
.
at
(
s
+
position
).
value
for
s
in
samples
]
ift
.
plot
([
A
.
at
(
position
).
value
,
A
.
at
(
MOCK_POSITION
).
value
]
+
powers
,
title
=
"power"
)
ift
.
plot_finish
(
nx
=
3
,
xsize
=
16
,
ysize
=
5
,
title
=
"results"
,
name
=
"results.png"
)
ift
.
plot_finish
(
nx
=
3
,
xsize
=
16
,
ysize
=
5
,
title
=
"results"
,
name
=
"results.png"
)
demos/plot_test.py
View file @
bfd57f63
...
...
@@ -18,7 +18,7 @@ def plot_test():
field_gl
=
ift
.
Field
.
from_global_data
(
gl_space
,
np
.
random
.
randn
(
32640
))
field_ps
=
ift
.
power_analyze
(
fft
.
times
(
field_rg2
))
#
#
Start various plotting tests
# Start various plotting tests
ift
.
plot
(
field_rg1_1
,
title
=
'Single plot'
)
ift
.
plot_finish
()
...
...
@@ -36,5 +36,6 @@ def plot_test():
ift
.
plot
(
field_rg2
,
title
=
'2d rg'
)
ift
.
plot_finish
(
nx
=
2
,
ny
=
3
,
title
=
'Five plots'
)
if
__name__
==
'__main__'
:
plot_test
()
nifty5/operators/dof_distributor.py
View file @
bfd57f63
...
...
@@ -71,7 +71,7 @@ class DOFDistributor(LinearOperator):
raise
ValueError
(
"incorrect dofdex domain"
)
ldat
=
dofdex
.
local_data
if
ldat
.
size
==
0
:
# can happen for weird configurations
if
ldat
.
size
==
0
:
# can happen for weird configurations
nbin
=
0
else
:
nbin
=
ldat
.
max
()
...
...
test/test_operators/test_adjoint.py
View file @
bfd57f63
...
...
@@ -39,9 +39,9 @@ class Consistency_Tests(unittest.TestCase):
[
np
.
float64
,
np
.
complex128
]))
def
testOperatorCombinations
(
self
,
sp
,
dtype
):
a
=
ift
.
DiagonalOperator
(
ift
.
Field
.
from_random
(
"normal"
,
sp
,
dtype
=
dtype
))
dtype
=
dtype
))
b
=
ift
.
DiagonalOperator
(
ift
.
Field
.
from_random
(
"normal"
,
sp
,
dtype
=
dtype
))
dtype
=
dtype
))
op
=
ift
.
SandwichOperator
.
make
(
a
,
b
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
op
=
a
*
b
...
...
@@ -66,7 +66,7 @@ class Consistency_Tests(unittest.TestCase):
_h_spaces
+
_p_spaces
+
_pow_spaces
,
[
np
.
float64
,
np
.
complex128
]))
def
testSelectionOperator
(
self
,
sp1
,
sp2
,
dtype
):
mdom
=
ift
.
MultiDomain
.
make
({
'a'
:
sp1
,
'b'
:
sp2
})
mdom
=
ift
.
MultiDomain
.
make
({
'a'
:
sp1
,
'b'
:
sp2
})
op
=
ift
.
SelectionOperator
(
mdom
,
'a'
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
...
...
@@ -86,20 +86,19 @@ class Consistency_Tests(unittest.TestCase):
def
testNullOperator
(
self
,
sp1
,
sp2
,
dtype
):
op
=
ift
.
NullOperator
(
sp1
,
sp2
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
mdom1
=
ift
.
MultiDomain
.
make
({
'a'
:
sp1
})
mdom2
=
ift
.
MultiDomain
.
make
({
'b'
:
sp2
})
mdom1
=
ift
.
MultiDomain
.
make
({
'a'
:
sp1
})
mdom2
=
ift
.
MultiDomain
.
make
({
'b'
:
sp2
})
op
=
ift
.
NullOperator
(
mdom1
,
mdom2
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
op
=
ift
.
NullOperator
(
sp1
,
mdom2
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
op
=
ift
.
NullOperator
(
mdom1
,
sp2
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
@
expand
(
product
(
_h_spaces
+
_p_spaces
+
_pow_spaces
,
@
expand
(
product
(
_h_spaces
+
_p_spaces
+
_pow_spaces
,
[
np
.
float64
,
np
.
complex128
]))
def
testMultiAdaptor
(
self
,
sp
,
dtype
):
mdom
=
ift
.
MultiDomain
.
make
({
'a'
:
sp
})
mdom
=
ift
.
MultiDomain
.
make
({
'a'
:
sp
})
op
=
ift
.
MultiAdaptor
(
mdom
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
...
...
@@ -109,19 +108,17 @@ class Consistency_Tests(unittest.TestCase):
op
=
ift
.
HarmonicSmoothingOperator
(
sp
,
0.1
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
@
expand
(
product
(
_h_spaces
+
_p_spaces
+
_pow_spaces
,
@
expand
(
product
(
_h_spaces
+
_p_spaces
+
_pow_spaces
,
[
np
.
float64
,
np
.
complex128
]))
def
testDOFDistributor
(
self
,
sp
,
dtype
):
#TODO: Test for DomainTuple
#
TODO: Test for DomainTuple
if
sp
.
size
<
4
:
return
dofdex
=
np
.
arange
(
sp
.
size
).
reshape
(
sp
.
shape
)
%
3
dofdex
=
np
.
arange
(
sp
.
size
).
reshape
(
sp
.
shape
)
%
3
dofdex
=
ift
.
Field
.
from_global_data
(
sp
,
dofdex
)
op
=
ift
.
DOFDistributor
(
dofdex
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
@
expand
(
product
(
_h_spaces
,
[
np
.
float64
,
np
.
complex128
]))
def
testPPO
(
self
,
sp
,
dtype
):
op
=
ift
.
PowerDistributor
(
target
=
sp
)
...
...
Write
Preview
Supports
Markdown
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