Commit d752bd3b by Martin Reinecke

### cleanup

parent 89767b59
 ... ... @@ -232,7 +232,7 @@ class Field(object): raise ValueError("No space for analysis specified.") if keep_phase_information: parts = self._hermitian_decomposition(self, False) parts = [self.real.copy(), self.imag.copy()] else: parts = [self] ... ... @@ -392,23 +392,13 @@ class Field(object): result_list[1] *= spec.imag if real_signal: result_list = [self._hermitian_decomposition(i, True)[0] for i in result_list] result_list = [i.real*np.sqrt(2.) for i in result_list] if real_power: return result_list[0] else: return result_list[0] + 1j*result_list[1] @staticmethod def _hermitian_decomposition(inp, preserve_gaussian_variance=False): if preserve_gaussian_variance: if not issubclass(inp.dtype.type, np.complexfloating): raise TypeError("complex input field is needed here") return (inp.real*np.sqrt(2.), inp.imag*np.sqrt(2.)) else: return (inp.real.copy(), inp.imag.copy()) def _spec_to_rescaler(self, spec, power_space_index): power_space = self.domain[power_space_index] ... ... @@ -615,7 +605,7 @@ class Field(object): return np.sqrt(np.abs(self.vdot(x=self))) def conjugate(self, inplace=False): """ Retruns the complex conjugate of the field. """ Returns the complex conjugate of the field. Parameters ---------- ... ...
 ... ... @@ -20,6 +20,7 @@ from builtins import next, range import numpy as np from itertools import product from functools import reduce from .domain_object import DomainObject def get_slice_list(shape, axes): ... ... @@ -94,7 +95,6 @@ def cast_axis_to_tuple(axis, length=None): def parse_domain(domain): from .domain_object import DomainObject if domain is None: return () if isinstance(domain, DomainObject): ... ...
 ... ... @@ -64,10 +64,8 @@ class ComposedOperator(LinearOperator): >>> x2 = RGSpace(10) >>> k1 = RGRGTransformation.get_codomain(x1) >>> k2 = RGRGTransformation.get_codomain(x2) >>> FFT1 = FFTOperator(domain=x1, target=k1, domain_dtype=np.float64, target_dtype=np.complex128) >>> FFT2 = FFTOperator(domain=x2, target=k2, domain_dtype=np.float64, target_dtype=np.complex128) >>> FFT1 = FFTOperator(domain=x1, target=k1) >>> FFT2 = FFTOperator(domain=x2, target=k2) >>> FFT = ComposedOperator((FFT1, FFT2) >>> f = Field.from_random('normal', domain=(x1,x2)) >>> FFT.times(f) ... ...
 ... ... @@ -132,7 +132,7 @@ class SlicingTransformation(Transformation): def buildLm(nr, lmax): new_dtype = np.result_type(nr.dtype, np.complex64) new_dtype = np.result_type(nr[0]*1j) size = (len(nr)-lmax-1)//2+lmax+1 res = np.empty([size], dtype=new_dtype) ... ... @@ -142,12 +142,7 @@ def buildLm(nr, lmax): def buildIdx(nr, lmax): if nr.dtype == np.dtype('complex64'): new_dtype = np.float32 elif nr.dtype == np.dtype('complex128'): new_dtype = np.float64 else: raise TypeError("dtype of nr not supported.") new_dtype = np.result_type(nr[0].real) size = (lmax+1)*(lmax+1) final = np.empty(size, dtype=new_dtype) ... ...
 ... ... @@ -287,9 +287,8 @@ class LinearOperator(with_metaclass( else: for i, space_index in enumerate(spaces): if x.domain[space_index] != self_domain[i]: raise ValueError( "The operator's and and field's domains don't " "match.") raise ValueError("The operator's and and field's domains " "don't match.") return spaces ... ...
 ... ... @@ -54,27 +54,6 @@ class Test_Interface(unittest.TestCase): class Test_Functionality(unittest.TestCase): @expand(product([True, False], [True, False], [(1,), (4,), (5,)], [(1,), (6,), (7,)])) def test_hermitian_decomposition(self, preserve, complexdata, s1, s2): np.random.seed(123) r1 = RGSpace(s1, harmonic=True) r2 = RGSpace(s2, harmonic=True) ra = RGSpace(s1+s2, harmonic=True) if preserve: complexdata=True v = np.random.random(s1+s2) if complexdata: v = v + 1j*np.random.random(s1+s2) f1 = Field(ra, val=v, copy=True) f2 = Field((r1, r2), val=v, copy=True) h1, a1 = Field._hermitian_decomposition(f1.val, preserve) h2, a2 = Field._hermitian_decomposition(f2.val, preserve) assert_almost_equal(h1, h2) assert_almost_equal(a1, a2) @expand(product([RGSpace((8,), harmonic=True), RGSpace((8, 8), harmonic=True, distances=0.123)], [RGSpace((8,), harmonic=True), ... ...
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