Skip to content
Snippets Groups Projects
Commit 7011e807 authored by Philipp Arras's avatar Philipp Arras
Browse files

PolarizationMatrixExponential: Add tests

parent eaaa37da
Branches
Tags
1 merge request!37Draft: Observation: introduce __hash__
# 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
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2021 Max-Planck-Society
import pytest
def list2fixture(lst):
@pytest.fixture(params=lst)
def myfixture(request):
return request.param
return myfixture
# 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
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2022 Max-Planck-Society, Philipp Arras
# Author: Philipp Arras
import nifty8 as ift
import pytest
import resolve as rve
from .common import list2fixture
pmp = pytest.mark.parametrize
pdom = list2fixture([rve.PolarizationSpace("I"),
rve.PolarizationSpace(["I", "Q", "U"]),
rve.PolarizationSpace(["I", "Q", "U", "V"]),
])
restdom = list2fixture([[ift.UnstructuredDomain(7)],
[ift.RGSpace([2, 3]), rve.IRGSpace([12., 13., 130])]
])
def test_jax_vs_nifty(pdom, restdom):
dom = tuple((pdom,)) + tuple(restdom)
op0 = rve.polarization_matrix_exponential(dom, False)
op1 = rve.polarization_matrix_exponential(dom, True)
loc = ift.from_random(op0.domain)
ift.extra.check_operator(op0, loc, ntries=3)
ift.extra.check_operator(op1, loc, ntries=3)
ift.extra.assert_allclose(op0(loc), op1(loc))
# 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
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2022 Max-Planck-Society, Philipp Arras
# Author: Philipp Arras
import nifty8 as ift
import pytest
import resolve as rve
from .common import list2fixture
pmp = pytest.mark.parametrize
pdom = list2fixture([rve.PolarizationSpace("I"),
rve.PolarizationSpace(["I", "Q", "U"]),
rve.PolarizationSpace(["I", "Q", "U", "V"]),
])
fdom = list2fixture([rve.IRGSpace([12., 13.])])
sdom = list2fixture([ift.RGSpace([12., 13.])])
def test_multi_field_stacker(pdom, fdom, sdom):
domain = rve.default_sky_domain(pdom=pdom, fdom=fdom, sdom=sdom)
op = rve.MultiFieldStacker(domain, 0, domain[0].labels)
ift.extra.check_linear_operator(op)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment