Commit 97790be1 authored by Philipp Arras's avatar Philipp Arras
Browse files

Add tests for imaginizer

parent 170fe8ec
Pipeline #75290 canceled with stages
in 1 minute and 30 seconds
...@@ -43,7 +43,8 @@ from .operators.outer_product_operator import OuterProduct ...@@ -43,7 +43,8 @@ from .operators.outer_product_operator import OuterProduct
from .operators.simple_linear_operators import ( from .operators.simple_linear_operators import (
VdotOperator, ConjugationOperator, Realizer, VdotOperator, ConjugationOperator, Realizer,
FieldAdapter, ducktape, GeometryRemover, NullOperator, FieldAdapter, ducktape, GeometryRemover, NullOperator,
MatrixProductOperator, PartialExtractor, SwitchSpacesOperator) MatrixProductOperator, PartialExtractor, SwitchSpacesOperator,
Imaginizer)
from .operators.value_inserter import ValueInserter from .operators.value_inserter import ValueInserter
from .operators.energy_operators import ( from .operators.energy_operators import (
EnergyOperator, GaussianEnergy, PoissonianEnergy, InverseGammaLikelihood, EnergyOperator, GaussianEnergy, PoissonianEnergy, InverseGammaLikelihood,
......
...@@ -127,7 +127,9 @@ class Imaginizer(EndomorphicOperator): ...@@ -127,7 +127,9 @@ class Imaginizer(EndomorphicOperator):
def apply(self, x, mode): def apply(self, x, mode):
self._check_input(x, mode) self._check_input(x, mode)
return x.imag if mode == self.TIMES:
return x.imag
return 1j*x
class FieldAdapter(LinearOperator): class FieldAdapter(LinearOperator):
......
...@@ -82,6 +82,13 @@ def testRealizer(sp): ...@@ -82,6 +82,13 @@ def testRealizer(sp):
only_r_linear=True) only_r_linear=True)
@pmp('sp', _h_spaces + _p_spaces + _pow_spaces)
def testImaginizer(sp):
op = ift.Imaginizer(sp)
ift.extra.consistency_check(op, np.complex128, np.float64,
only_r_linear=True)
@pmp('sp', _h_spaces + _p_spaces + _pow_spaces) @pmp('sp', _h_spaces + _p_spaces + _pow_spaces)
def testConjugationOperator(sp): def testConjugationOperator(sp):
op = ift.ConjugationOperator(sp) op = ift.ConjugationOperator(sp)
......
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