Commit 674c912d authored by Martin Reinecke's avatar Martin Reinecke
Browse files

Merge branch 'nifty6_more_scaling_ops' into 'NIFTy_6'

No DiagonalOperator if ScalingOperator is fine

See merge request !407
parents 128309f6 9ad27dfe
Pipeline #70459 passed with stages
in 16 minutes
......@@ -69,7 +69,9 @@ def _normal(mean, sig, key, N=0):
if N == 0:
domain = DomainTuple.scalar_domain()
mean, sig = np.asfarray(mean), np.asfarray(sig)
return Adder(makeField(domain, mean)) @ (
sig * ducktape(domain, None, key))
domain = UnstructuredDomain(N)
mean, sig = (_reshaper(param, N) for param in (mean, sig))
return Adder(makeField(domain, mean)) @ (DiagonalOperator(
......@@ -17,7 +17,6 @@
import numpy as np
from ..sugar import full
from .endomorphic_operator import EndomorphicOperator
......@@ -60,12 +59,14 @@ class ScalingOperator(EndomorphicOperator):
self._capability = self._all_ops
def apply(self, x, mode):
from ..sugar import full
self._check_input(x, mode)
fct = self._factor
if fct == 1.:
return x
if fct == 0.:
return full(self.domain, 0.)
return full(x.domain, 0.)
......@@ -25,13 +25,13 @@ from . import utilities
from .domain_tuple import DomainTuple
from .domains.power_space import PowerSpace
from .field import Field
from .logger import logger
from .multi_domain import MultiDomain
from .multi_field import MultiField
from .operators.block_diagonal_operator import BlockDiagonalOperator
from .operators.diagonal_operator import DiagonalOperator
from .operators.distributors import PowerDistributor
from .operators.operator import Operator
from .operators.scaling_operator import ScalingOperator
from .plot import Plot
__all__ = ['PS_field', 'power_analyze', 'create_power_operator',
......@@ -327,6 +327,8 @@ def makeOp(input):
input : None, Field or MultiField
- if None, None is returned.
- if Field on scalar-domain, a ScalingOperator with the coefficient
given by the Field is returned.
- if Field, a DiagonalOperator with the coefficients given by this
Field is returned.
- if MultiField, a BlockDiagonalOperator with entries given by this
......@@ -338,6 +340,8 @@ def makeOp(input):
if input is None:
return None
if input.domain is DomainTuple.scalar_domain():
return ScalingOperator(input.domain, float(input.val))
if isinstance(input, Field):
return DiagonalOperator(input)
if isinstance(input, MultiField):
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