Commit 119da1a5 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

simplifications

parent a2d0f803
Pipeline #22720 passed with stage
in 4 minutes and 49 seconds
......@@ -75,10 +75,6 @@ class DomainTuple(object):
def __getitem__(self, i):
return self._dom[i]
@property
def domains(self):
return self._dom
@property
def shape(self):
return self._shape
......@@ -108,7 +104,7 @@ class DomainTuple(object):
return not self.__eq__(x)
def __str__(self):
res = "DomainTuple, len: " + str(len(self.domains))
for i in self.domains:
res = "DomainTuple, len: " + str(len(self))
for i in self:
res += "\n" + str(i)
return res
......@@ -81,9 +81,9 @@ class DiagonalOperator(EndomorphicOperator):
else:
self._spaces = cast_iseq_to_tuple(spaces)
nspc = len(self._spaces)
if nspc != len(diagonal.domain.domains):
if nspc != len(diagonal.domain):
raise ValueError("spaces and domain must have the same length")
if nspc > len(self._domain.domains):
if nspc > len(self._domain):
raise ValueError("too many spaces")
if nspc > len(set(self._spaces)):
raise ValueError("non-unique space indices")
......@@ -92,7 +92,7 @@ class DiagonalOperator(EndomorphicOperator):
for i, j in enumerate(self._spaces):
if diagonal.domain[i] != self._domain[j]:
raise ValueError("domain mismatch")
if self._spaces == tuple(range(len(self._domain.domains))):
if self._spaces == tuple(range(len(self._domain))):
self._spaces = None # shortcut
self._diagonal = diagonal.copy()
......
......@@ -79,11 +79,11 @@ class FFTOperator(LinearOperator):
# Initialize domain and target
self._domain = DomainTuple.make(domain)
if space is None:
if len(self._domain.domains) != 1:
if len(self._domain) != 1:
raise ValueError("need a Field with exactly one domain")
space = 0
space = int(space)
if space < 0 or space >= len(self._domain.domains):
if space < 0 or space >= len(self._domain):
raise ValueError("space index out of range")
self._space = space
......
......@@ -11,11 +11,11 @@ class FFTSmoothingOperator(EndomorphicOperator):
dom = DomainTuple.make(domain)
self._sigma = float(sigma)
if space is None:
if len(dom.domains) != 1:
if len(dom) != 1:
raise ValueError("need a Field with exactly one domain")
space = 0
space = int(space)
if space < 0 or space >= len(dom.domains):
if space < 0 or space >= len(dom):
raise ValueError("space index out of range")
self._space = space
......
......@@ -45,11 +45,11 @@ class LaplaceOperator(EndomorphicOperator):
super(LaplaceOperator, self).__init__()
self._domain = DomainTuple.make(domain)
if space is None:
if len(self._domain.domains) != 1:
if len(self._domain) != 1:
raise ValueError("need a Field with exactly one domain")
space = 0
space = int(space)
if space < 0 or space >= len(self._domain.domains):
if space < 0 or space >= len(self._domain):
raise ValueError("space index out of range")
self._space = space
......
......@@ -261,7 +261,7 @@ def create_composed_fft_operator(domain, codomain=None, all_to='other'):
if codomain is None:
codomain = [None]*len(domain)
interdomain = list(domain.domains)
interdomain = list(domain)
for i, space in enumerate(domain):
if not isinstance(space, Space):
continue
......
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