Commit 9eeec145 authored by Philipp Arras's avatar Philipp Arras
Browse files

Merge branch 'complex_fixups' into 'NIFTy_6'

Complex fixups

See merge request !497
parents 9855fce6 70bb83ae
Pipeline #75411 passed with stages
in 10 minutes and 22 seconds
...@@ -219,7 +219,7 @@ def consistency_check(op, domain_dtype=np.float64, target_dtype=np.float64, ...@@ -219,7 +219,7 @@ def consistency_check(op, domain_dtype=np.float64, target_dtype=np.float64,
def _get_acceptable_location(op, loc, lin): def _get_acceptable_location(op, loc, lin):
if not np.isfinite(lin.val.s_sum()): if not np.isfinite(lin.val.s_sum()):
raise ValueError('Initial value must be finite') raise ValueError('Initial value must be finite')
dir = from_random(loc.domain, "normal") dir = from_random(loc.domain, dtype=loc.dtype)
dirder = lin.jac(dir) dirder = lin.jac(dir)
if dirder.norm() == 0: if dirder.norm() == 0:
dir = dir * (lin.val.norm()*1e-5) dir = dir * (lin.val.norm()*1e-5)
......
...@@ -11,19 +11,19 @@ ...@@ -11,19 +11,19 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# Copyright(C) 2013-2019 Max-Planck-Society # Copyright(C) 2013-2020 Max-Planck-Society
# #
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik. # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import numpy as np
from ..domain_tuple import DomainTuple from ..domain_tuple import DomainTuple
from ..multi_domain import MultiDomain
from ..domains.unstructured_domain import UnstructuredDomain from ..domains.unstructured_domain import UnstructuredDomain
from ..field import Field from ..field import Field
from ..multi_domain import MultiDomain
from ..multi_field import MultiField from ..multi_field import MultiField
from .linear_operator import LinearOperator
from .endomorphic_operator import EndomorphicOperator from .endomorphic_operator import EndomorphicOperator
from .. import utilities from .linear_operator import LinearOperator
import numpy as np
class VdotOperator(LinearOperator): class VdotOperator(LinearOperator):
...@@ -128,7 +128,11 @@ class Imaginizer(EndomorphicOperator): ...@@ -128,7 +128,11 @@ class Imaginizer(EndomorphicOperator):
def apply(self, x, mode): def apply(self, x, mode):
self._check_input(x, mode) self._check_input(x, mode)
if mode == self.TIMES: if mode == self.TIMES:
if not np.issubdtype(x.dtype, np.complexfloating):
raise ValueError
return x.imag return x.imag
if x.dtype not in (np.float64, np.float32):
raise ValueError
return 1j*x return 1j*x
......
...@@ -80,6 +80,8 @@ def testImaginizer(sp): ...@@ -80,6 +80,8 @@ def testImaginizer(sp):
op = ift.Imaginizer(sp) op = ift.Imaginizer(sp)
ift.extra.consistency_check(op, np.complex128, np.float64, ift.extra.consistency_check(op, np.complex128, np.float64,
only_r_linear=True) only_r_linear=True)
loc = ift.from_random(op.domain, dtype=np.complex128)
ift.extra.check_jacobian_consistency(op, loc)
@pmp('sp', _h_spaces + _p_spaces + _pow_spaces) @pmp('sp', _h_spaces + _p_spaces + _pow_spaces)
......
Supports Markdown
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