Skip to content

Commit

Permalink
STY: PEP8 on all files
Browse files Browse the repository at this point in the history
  • Loading branch information
jjhelmus committed Jan 12, 2015
1 parent b4d3d79 commit 1e64796
Show file tree
Hide file tree
Showing 28 changed files with 273 additions and 283 deletions.
36 changes: 18 additions & 18 deletions nmrglue/analysis/linesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def estimate_scales(spectrum, centers, box_width, scale_axis=0):
# loop over the box centers
for bc in bcenters:

# calculate box limits
# calculate box limits
bmin = [max(c - w, 0) for c, w in zip(bc, box_width)]
bmax = [min(c + w + 1, s) for c, w, s in zip(bc, box_width, shape)]

Expand Down Expand Up @@ -502,16 +502,16 @@ def fit_NDregion(region, lineshapes, params, amps, bounds=None,
raise ValueError(err)

# DEBUGGING
#print("--------------------------------")
#print(region)
#print(ls_classes)
#print(p0)
#print(p_bounds)
#print(n_peaks)
#print(dim_nparam)
#print("=================================")
#for i,j in zip(p0,p_bounds):
# print(i, j)
# print("--------------------------------")
# print(region)
# print(ls_classes)
# print(p0)
# print(p_bounds)
# print(n_peaks)
# print(dim_nparam)
# print("=================================")
# for i,j in zip(p0,p_bounds):
# print(i, j)

# include full_output=True when errors requested
if error_flag:
Expand All @@ -521,7 +521,7 @@ def fit_NDregion(region, lineshapes, params, amps, bounds=None,
r = f_NDregion(region, ls_classes, p0, p_bounds, n_peaks, wmask, **kw)

# DEBUGGING
#print(r)
# print(r)

# unpack results depending of if full output requested
if "full_output" in kw and kw["full_output"]:
Expand Down Expand Up @@ -622,10 +622,10 @@ def sim_NDregion(shape, lineshapes, params, amps):
p = list(amps) + p # amplitudes appended to front of p

# DEBUGGING
#print("p",p)
#print("shape",shape)
#print("ls_classes",ls_classes)
#print("n_peaks",n_peaks)
# print("p",p)
# print("shape",shape)
# print("ls_classes",ls_classes)
# print("n_peaks",n_peaks)

return s_NDregion(p, shape, ls_classes, n_peaks)

Expand Down Expand Up @@ -757,10 +757,10 @@ def s_single_NDregion(p, shape, ls_classes):
r = np.array(A, dtype='float')

for length, ls_class in zip(shape, ls_classes):
#print("Making lineshape of", ls_class.name, "with length:", length)
# print("Making lineshape of", ls_class.name, "with length:", length)
s_p = [p.pop(0) for i in range(ls_class.nparam(length))]
ls = ls_class.sim(length, s_p)
#print("Lineshape is:", ls)
# print("Lineshape is:", ls)
r = np.kron(r, ls) # vector direct product flattened
return r.reshape(shape)

Expand Down
4 changes: 2 additions & 2 deletions nmrglue/analysis/peakpick.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ def pick(data, pthres, nthres=None, msep=None, algorithm='connected',
seg_slices = pseg + nseg
scales = [[]] * len(locations)
amps = [[]] * len(locations)
#scales = np.zeros(np.array(locations).shape,dtype=float)
#amps = np.zeros(len(locations),dtype=float)
# scales = np.zeros(np.array(locations).shape,dtype=float)
# amps = np.zeros(len(locations),dtype=float)

for i, (l, seg_slice) in enumerate(zip(locations, seg_slices)):
null, scales[i], amps[i] = guess_params_slice(data, l, seg_slice,
Expand Down
2 changes: 1 addition & 1 deletion nmrglue/fileio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from . import bruker
from . import convert
#from . import glue
# from . import glue
from . import pipe
from . import rnmrtk
from . import simpson
Expand Down
22 changes: 11 additions & 11 deletions nmrglue/fileio/bruker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ def rm_dig_filter(data, decim, dspfvs, grpdly=0):
add = int(max(skip - 6, 0)) # 6 less, or 0

# DEBUG
#print("phase: %f, skip: %i add: %i"%(phase,skip,add))
# print("phase: %f, skip: %i add: %i"%(phase,skip,add))

# frequency shift
pdata = proc_base.fsh2(data, phase)
Expand Down Expand Up @@ -1524,7 +1524,7 @@ def read_jcamp(filename):
break

if line[:6] == "##END=":
#print("End of file")
# print("End of file")
break
elif line[:2] == "$$":
dic["_comments"].append(line)
Expand Down Expand Up @@ -1797,7 +1797,7 @@ def read_pprog(filename):

# skip blank lines and include lines
if text == "" or text[0] == "#":
#print(line,"--Blank, Comment or Include")
# print(line,"--Blank, Comment or Include")
continue

# see if we have quotes and have an assigment
Expand All @@ -1811,13 +1811,13 @@ def read_pprog(filename):
if len(t) >= 2:
key, value = t[0], t[1]
var[key] = value
#print(line,"--Assignment")
# print(line,"--Assignment")
else:
pass
#print(line,"--Statement")
# print(line,"--Statement")
continue
else:
#print(line,"--Statement")
# print(line,"--Statement")
continue

# loops begin with lo
Expand All @@ -1828,7 +1828,7 @@ def read_pprog(filename):
incr.append([])
phase.append([])
ph_extra.append([])
#print(line,"--Loop")
# print(line,"--Loop")
continue

tokens = text.split()
Expand All @@ -1839,12 +1839,12 @@ def read_pprog(filename):
# store N to incr list
if token2.startswith('id') or token2.startswith('dd'):
incr[len(loop)].append(int(token2[2:]))
#print(line,"--Increment")
# print(line,"--Increment")
continue

if token2.startswith("ipu") or token2.startswith("dpu"):
incr[len(loop)].append(int(token2[3:]))
#print(line,"--Increment")
# print(line,"--Increment")
continue

# phase statement have ip or dp
Expand All @@ -1859,10 +1859,10 @@ def read_pprog(filename):
ph_extra[len(loop)].append("")
else:
ph_extra[len(loop)].append(text[last:].strip())
#print(line,"--Phase")
# print(line,"--Phase")
continue

#print(line,"--Unimportant")
# print(line,"--Unimportant")

f.close()

Expand Down
2 changes: 1 addition & 1 deletion nmrglue/fileio/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __procdata(self):
# processing for input type
# sign alt. indirect dimension
if data.ndim >= 2 and "alt_id_sign" in self._iproc:
#data[1::2] = -data[1::2]
# data[1::2] = -data[1::2]
s = [slice(None, None, None)] * data.ndim
for i in range(data.ndim - 1):
s[i] = slice(1, None, 2)
Expand Down
18 changes: 9 additions & 9 deletions nmrglue/fileio/fileiobase.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def create_blank_udic(ndim):
d["complex"] = True # Quadrature, True when dimension is complex
d["obs"] = 999.99 # Observation frequency in MHz
d["car"] = 999.99 # Carrier frequency in Hz
d["size"] = 1 # Number of points in dimension based on the
# shape of the data array. As such the direct
# dimension (-1) size is R|I, all indirect
# dimensions are R+I
# Number of points in dimension based on the shape of the data array.
# As such the direct dimension (-1) size is R|I, all indirect
# dimensions are R+I
d["size"] = 1

d["label"] = ["X", "Y", "Z", "A"][i] # name of dimension

Expand Down Expand Up @@ -141,18 +141,18 @@ def __unit2pnt(self, val, units):
pts = self.__us2pts(val)
else:
raise ValueError("invalid unit type")
#if self._cplx:
# return pts+round(pts)
#else:
# if self._cplx:
# return pts+round(pts)
# else:
return pts

def __pnt2unit(self, val, units):
"""
Convert points to units
"""
units = units.upper()
#if self._cplx:
# val = val-round(val)
# if self._cplx:
# val = val-round(val)
if units == "PPM":
k = self.__pts2ppm(val)
elif units == "HZ":
Expand Down
30 changes: 15 additions & 15 deletions nmrglue/fileio/pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def read_table(filename):
dtd['formats'] = [p2f[i[-1]] for i in pformat]

# DEBUG
#print(dtd['names'],dtd['formats'])
# print(dtd['names'],dtd['formats'])
s = StringIO("".join(dl))

rec = np.recfromtxt(s, dtype=dtd, comments='XXXXXXXXXXX')
Expand Down Expand Up @@ -371,12 +371,12 @@ def add_axis_to_dic(dic, adic, n):

# origin (last point) is CAR*OBS-SW*(N/2-1)/N
# see Fig 3.1 on p.36 of Hoch and Stern
#print("fn:",n)
#print("CAR:",dic[fn+"CAR"])
#print("OBS:",dic[fn+"OBS"])
#print("SW:",dic[fn+"SW"])
#print("osize:",osize)
#print("CENTER:",dic[fn+"CENTER"])
# print("fn:",n)
# print("CAR:",dic[fn+"CAR"])
# print("OBS:",dic[fn+"OBS"])
# print("SW:",dic[fn+"SW"])
# print("osize:",osize)
# print("CENTER:",dic[fn+"CENTER"])
dic[fn + "ORIG"] = (dic[fn + "CAR"] * dic[fn + "OBS"] - dic[fn + "SW"] *
(osize - dic[fn + "CENTER"]) / osize)

Expand Down Expand Up @@ -1049,7 +1049,7 @@ def put_data(filename, fdata, data, overwrite=False):
Put fdata and data to 2D NMRPipe.
"""
if data.dtype != 'float32':
#print(data.dtype)
# print(data.dtype)
raise TypeError('data.dtype is not float32')
if fdata.dtype != 'float32':
raise TypeError('fdata.dtype is not float32')
Expand Down Expand Up @@ -1106,7 +1106,7 @@ def write_slice_3D(filemask, dic, data, shape, slices):
# loop over the requested z-slice
for i, f in enumerate(fnames[sz]):

#print("i:",i,"f:",f)
# print("i:",i,"f:",f)
if os.path.isfile(f) is False:
# file doesn't exist, create a empty one
ndata = np.zeros((dy, dx), dtype=data.dtype)
Expand Down Expand Up @@ -1331,7 +1331,7 @@ def __init__(self, filemask, in_lead="x", out_lead="DEFAULT"):
elif self.in_lead == "z":
# transpose to Y(XZ)
self.idic, self.pipe_3d = transpose_3D(self.dic, self.pipe_3d,
(1, 2, 0))
(1, 2, 0))
fn = "FDF" + str(int(self.idic["FDDIMORDER1"]))
if self.idic[fn + "QUADFLAG"] != 1.0: # z axis is complex
self.needs_pack_complex = True
Expand Down Expand Up @@ -1408,11 +1408,11 @@ def write(self, filemask, plane, dic):
raise ValueError("invalid in_lead") # this should never be raised

# DEBUGGING
#print("Writing out slice :",self.i)
#print("shape:",shape)
#print("plane.shape",plane.shape)
#print("sx,sy,sz",sx,sy,sz)
#print(dic["FDFILECOUNT"])
# print("Writing out slice :",self.i)
# print("shape:",shape)
# print("plane.shape",plane.shape)
# print("sx,sy,sz",sx,sy,sz)
# print(dic["FDFILECOUNT"])
write_slice_3D(filemask, dic, plane, shape, (sz, sy, sx))

#####################
Expand Down
12 changes: 6 additions & 6 deletions nmrglue/fileio/rnmrtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,12 +524,12 @@ def interleave_data(data):
Interleave real, imag data in data
"""
return data.view('float32')
#size = list(data.shape)
#size[-1] = size[-1]*2
#data_out = np.empty(size,dtype="float32")
#data_out[...,::2] = data.real
#data_out[...,1::2] = data.imag
#return data_out
# size = list(data.shape)
# size[-1] = size[-1]*2
# data_out = np.empty(size,dtype="float32")
# data_out[...,::2] = data.real
# data_out[...,1::2] = data.imag
# return data_out

######################
# low-memory objects #
Expand Down
6 changes: 3 additions & 3 deletions nmrglue/fileio/simpson.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def read_text(filename):
dic[key] = int(dic[key])

# DEBUGGING
#return dic
# return dic

if "NI" in dic: # 2D data
data = np.empty((dic['NI'], dic['NP']), dtype='complex64')
Expand Down Expand Up @@ -328,7 +328,7 @@ def read_binary(filename):
dic[key] = int(dic[key])

# DEBUGGING
#return dic, f
# return dic, f

# extract characters from data block
chardata = "".join([line.strip('\n') for line in f])
Expand All @@ -343,7 +343,7 @@ def read_binary(filename):
bytes += chars2bytes(chardata[i * 4:(i + 1) * 4])

# DEBUGGING
#return dic, bytes
# return dic, bytes
# convert every 4 'bytes' to a float, then complex data
num_points, _num_pad = divmod(len(bytes), 4)
data = np.empty((num_points, ), dtype='float32')
Expand Down

0 comments on commit 1e64796

Please sign in to comment.