Commit 67337be2 authored by Philipp Arras's avatar Philipp Arras
Browse files

Add test for partial multifield inserts

parent 431b7ea9
Pipeline #65153 passed with stages
in 8 minutes and 18 seconds
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <>.
# Copyright(C) 2013-2019 Max-Planck-Society
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import numpy as np
import pytest
from numpy.testing import assert_, assert_allclose
import nifty6 as ift
from ..common import list2fixture
pmp = pytest.mark.parametrize
dtype = list2fixture([np.float64, np.float32, np.complex64, np.complex128])
def test_part_mf_insert():
dom = ift.RGSpace(3)
op1 = ift.ScalingOperator(dom, 1.32).ducktape('a').ducktape_left('a1')
op2 = ift.ScalingOperator(dom, 1).exp().ducktape('b').ducktape_left('b1')
op3 = ift.ScalingOperator(dom, 1).sin().ducktape('c').ducktape_left('c1')
op4 = ift.ScalingOperator(dom, 1).ducktape('c0').ducktape_left('c')**2
op5 = ift.ScalingOperator(dom, 1).tan().ducktape('d0').ducktape_left('d')
a = op1 + op2 + op3
b = op4 + op5
op = a.partial_insert(b)
fld = ift.from_random('normal', op.domain)
ift.extra.check_jacobian_consistency(op, fld)
assert_(op.domain is ift.MultiDomain.union(
[op1.domain, op2.domain, op4.domain, op5.domain]))
assert_( is ift.MultiDomain.union(
x, y = fld.val, op(fld).val
assert_allclose(y['a1'], x['a']*1.32)
assert_allclose(y['b1'], np.exp(x['b']))
assert_allclose(y['c1'], np.sin(x['c0']**2))
assert_allclose(y['d'], np.tan(x['d0']))
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