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
cdb98660
Commit
cdb98660
authored
Jan 15, 2019
by
Philipp Arras
Browse files
fixup! Add ValueInserter
parent
04a93f9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
test/test_operators/test_adjoint.py
View file @
cdb98660
...
...
@@ -15,8 +15,6 @@
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
from
random
import
randint
import
numpy
as
np
import
pytest
...
...
@@ -269,7 +267,9 @@ def testOuter(fdomain, domain):
@
pmp
(
'sp'
,
_h_spaces
+
_p_spaces
+
_pow_spaces
)
def
testValueInserter
(
sp
):
ind
=
tuple
([
randint
(
0
,
ss
-
1
)
for
ss
in
sp
.
shape
])
@
pmp
(
'seed'
,
[
12
,
3
])
def
testValueInserter
(
sp
,
seed
):
np
.
random
.
seed
(
seed
)
ind
=
tuple
([
np
.
random
.
randint
(
0
,
ss
-
1
)
for
ss
in
sp
.
shape
])
op
=
ift
.
ValueInserter
(
sp
,
ind
)
ift
.
extra
.
consistency_check
(
op
)
test/test_operators/test_value_inserter.py
View file @
cdb98660
...
...
@@ -15,8 +15,6 @@
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
from
random
import
randint
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
...
...
@@ -31,11 +29,13 @@ import nifty5 as ift
ift
.
HPSpace
(
4
),
ift
.
GLSpace
(
4
)
])
def
test_value_inserter
(
sp
):
ind
=
tuple
([
randint
(
0
,
ss
-
1
)
for
ss
in
sp
.
shape
])
@
pytest
.
mark
.
parametrize
(
'seed'
,
[
13
,
2
])
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
()
inp
=
f
.
to_global_data
()
[
0
]
ret
=
op
(
f
).
to_global_data
()
assert_
(
ret
[
ind
]
==
inp
)
assert_
(
np
.
sum
(
ret
)
==
inp
)
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