Commit 85db45e4 by Martin Reinecke

### make ScalingOperator work on MultiField

parent e759eb60
Pipeline #29014 passed with stages
in 3 minutes and 27 seconds
 ... @@ -32,6 +32,13 @@ class MultiField(object): ... @@ -32,6 +32,13 @@ class MultiField(object): def dtype(self): def dtype(self): return {key: val.dtype for key, val in self._val.items()} return {key: val.dtype for key, val in self._val.items()} @staticmethod def from_random(random_type, domain, dtype=np.float64, **kwargs): dtype = self.build_dtype(dtype) return MultiField({key: Field.from_random(random_type, domain[key], dtype[key], **kwargs) for key in domain.keys}) def _check_domain(self, other): def _check_domain(self, other): if other.domain != self.domain: if other.domain != self.domain: raise ValueError("domains are incompatible.") raise ValueError("domains are incompatible.") ... ...
 ... @@ -19,6 +19,7 @@ ... @@ -19,6 +19,7 @@ from __future__ import division from __future__ import division import numpy as np import numpy as np from ..field import Field from ..field import Field from ..multi.multi_field import MultiField from ..domain_tuple import DomainTuple from ..domain_tuple import DomainTuple from .endomorphic_operator import EndomorphicOperator from .endomorphic_operator import EndomorphicOperator ... @@ -61,7 +62,7 @@ class ScalingOperator(EndomorphicOperator): ... @@ -61,7 +62,7 @@ class ScalingOperator(EndomorphicOperator): if self._factor == 1.: if self._factor == 1.: return x.copy() return x.copy() if self._factor == 0.: if self._factor == 0.: return Field.zeros_like(x) return x.zeros_like(x) if mode == self.TIMES: if mode == self.TIMES: return x*self._factor return x*self._factor ... @@ -103,5 +104,6 @@ class ScalingOperator(EndomorphicOperator): ... @@ -103,5 +104,6 @@ class ScalingOperator(EndomorphicOperator): if fct.real == 0. and from_inverse: if fct.real == 0. and from_inverse: raise ValueError("operator not positive definite") raise ValueError("operator not positive definite") fct = 1./np.sqrt(fct) if from_inverse else np.sqrt(fct) fct = 1./np.sqrt(fct) if from_inverse else np.sqrt(fct) return Field.from_random( cls = Field if isinstance(self._domain, DomainTuple) else MultiField return cls.from_random( random_type="normal", domain=self._domain, std=fct, dtype=dtype) random_type="normal", domain=self._domain, std=fct, dtype=dtype)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!