Commit 97eb9cf2 authored by Philipp Arras's avatar Philipp Arras
Browse files


parent 0ebb2050
......@@ -7,8 +7,8 @@ from ..domain_tuple import DomainTuple
from import RGSpace
from ..field import Field
class CentralZeroPadder(LinearOperator):
class CentralZeroPadder(LinearOperator):
def __init__(self, domain, new_shape, space=0):
super(CentralZeroPadder, self).__init__()
......@@ -22,7 +22,7 @@ class CentralZeroPadder(LinearOperator):
raise TypeError("RGSpace must not be harmonic")
if len(new_shape) != len(dom.shape):
raise ValueError("Shape missmatch")
if any( [a<b for a,b in zip(new_shape, dom.shape)]):
if any([a < b for a, b in zip(new_shape, dom.shape)]):
raise ValueError("New shape must be larger than old shape")
tgt = RGSpace(new_shape, dom.distances)
......@@ -36,16 +36,16 @@ class CentralZeroPadder(LinearOperator):
if i in axes:
slicer_fw = slice(0, self._domain.shape[i]/2)
slicer_bw = slice(-self._domain.shape[i]/2, None)
slicer.append( [slicer_fw, slicer_bw ] )
slicer.append([slicer_fw, slicer_bw])
self.slicer = list(itertools.product(*slicer))
for i in range(len(self.slicer)):
for j in range(len(self._domain.shape)):
if not j in axes:
if j not in axes:
tmp = (list(self.slicer[i]))
tmp.insert(j, slice(None))
self.slicer[i] = tmp
def domain(self):
return self._domain
......@@ -61,15 +61,15 @@ class CentralZeroPadder(LinearOperator):
def apply(self, x, mode):
self._check_input(x, mode)
x = x.val
if mode == self.TIMES:
y = np.zeros( self._target.shape )
y = np.zeros(self._target.shape)
for i in self.slicer:
y[i] = x[i]
return Field(self._target, val=y)
if mode == self.ADJOINT_TIMES:
y = np.zeros( self._domain.shape )
y = np.zeros(self._domain.shape)
for i in self.slicer:
y[i] = x[i]
return Field(self._domain, val=y)
return Field(self._domain, val=y)
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