Commit cdb98660 authored by Philipp Arras's avatar Philipp Arras
Browse files

fixup! Add ValueInserter

parent 04a93f9e
......@@ -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)
......@@ -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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment