Commit cc3a4832 authored by Momme Butenschön's avatar Momme Butenschön

Fixed white space issues and python3 compability.

parent 70418ef2
......@@ -12,31 +12,31 @@ class Map2D:
dims (integer or list of integers): provides the dimensions to collaps into rows (axis=0) or columns (axis=1).
axis (integer): collaps dimensions into row (0) or column (1).
"""
rdims = (type(dims)==type(0) and [dims] or list(dims))
Shape=list(data.shape)
Len=len(Shape)
cdims=range(Len)
for n,d in enumerate(rdims):
if d<0:
d=Len+d
rdims[n]=d
cdims.remove(d)
rdims.sort()
if axis==1:
coldims=tuple(rdims)
rowdims=tuple(cdims)
else:
coldims=tuple(cdims)
rowdims=tuple(rdims)
self.rowShape=tuple([data.shape[d] for d in rowdims])
self.columnShape=tuple([data.shape[d] for d in coldims])
self.rows=array(self.rowShape).prod()
self.columns=array(self.columnShape).prod()
self.map=(rowdims+coldims)
remap=range(len(self.rowShape))
for n in xrange(len(self.columnShape)):
remap.insert(coldims[n],n+len(self.rowShape))
self.remap=tuple(remap)
rdims = (type(dims)==type(0) and [dims] or list(dims))
Shape=list(data.shape)
Len=len(Shape)
cdims=list(range(Len))
for n,d in enumerate(rdims):
if d<0:
d=Len+d
rdims[n]=d
cdims.remove(d)
rdims.sort()
if axis==1:
coldims=tuple(rdims)
rowdims=tuple(cdims)
else:
coldims=tuple(cdims)
rowdims=tuple(rdims)
self.rowShape=tuple([data.shape[d] for d in rowdims])
self.columnShape=tuple([data.shape[d] for d in coldims])
self.rows=array(self.rowShape).prod()
self.columns=array(self.columnShape).prod()
self.map=(rowdims+coldims)
remap=list(range(len(self.rowShape)))
for n in range(len(self.columnShape)):
remap.insert(coldims[n],n+len(self.rowShape))
self.remap=tuple(remap)
def __call__(self,data):
"""
......@@ -45,7 +45,7 @@ class Map2D:
data (numpy.array): input data, needs to have same dimensions
as original input data.
"""
return data.transpose(self.map).reshape((self.rows,self.columns,))
return data.transpose(self.map).reshape((self.rows,self.columns,))
inv = lambda self,data: data.reshape(self.rowShape+self.columnShape).transpose(self.remap)
......
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