Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 103cb48

Browse files
committed
STY: pep8 on process modules
1 parent c62584c commit 103cb48

2 files changed

Lines changed: 47 additions & 47 deletions

File tree

nmrglue/process/pipe_proc.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def clean_minmax(dic):
173173

174174

175175
def apod(dic, data, qName=None, q1=1.0, q2=1.0, q3=1.0, c=1.0, start=1,
176-
size='default', inv=False, one=False, hdr=False):
176+
size='default', inv=False, one=False, hdr=False):
177177
"""
178178
Generic apodization.
179179
@@ -259,7 +259,7 @@ def apod(dic, data, qName=None, q1=1.0, q2=1.0, q3=1.0, c=1.0, start=1,
259259

260260

261261
def em(dic, data, lb=0.0, c=1.0, start=1, size='default', inv=False, one=False,
262-
hdr=False):
262+
hdr=False):
263263
"""
264264
Exponential apodization.
265265
@@ -322,7 +322,7 @@ def em(dic, data, lb=0.0, c=1.0, start=1, size='default', inv=False, one=False,
322322
else:
323323
stop = start + size
324324
data[..., start:stop] = p.em(data[..., start:stop], lb=flb, inv=inv)
325-
if one == False:
325+
if one is False:
326326
data[..., :start] = 0.0
327327
data[..., stop:] = 0.0
328328

@@ -337,7 +337,7 @@ def em(dic, data, lb=0.0, c=1.0, start=1, size='default', inv=False, one=False,
337337

338338

339339
def gm(dic, data, g1=0.0, g2=0.0, g3=0.0, c=1.0, start=1, size='default',
340-
inv=False, one=False, hdr=False):
340+
inv=False, one=False, hdr=False):
341341
"""
342342
Lorentz-to-Gauss apodization
343343
@@ -415,7 +415,7 @@ def gm(dic, data, g1=0.0, g2=0.0, g3=0.0, c=1.0, start=1, size='default',
415415
#print start,stop,g1p,g2p,g3p
416416
data[..., start:stop] = p.gm(data[..., start:stop], g1p, g2p, g3p,
417417
inv=inv)
418-
if one == False:
418+
if one is False:
419419
data[..., :start] = 0.0
420420
data[..., stop:] = 0.0
421421

@@ -498,7 +498,7 @@ def gmb(dic, data, lb=0.0, gb=0.0, c=1.0, start=1, size='default', inv=False,
498498
else:
499499
stop = start + size
500500
data[..., start:stop] = p.gmb(data[..., start:stop], a, b, inv=inv)
501-
if one == False:
501+
if one is False:
502502
data[..., :start] = 0.0
503503
data[..., stop:] = 0.0
504504

@@ -513,7 +513,7 @@ def gmb(dic, data, lb=0.0, gb=0.0, c=1.0, start=1, size='default', inv=False,
513513

514514

515515
def jmod(dic, data, off=0.0, j=0.0, lb=0.0, sin=False, cos=False, c=1.0,
516-
start=1, size='default', inv=False, one=False, hdr=False):
516+
start=1, size='default', inv=False, one=False, hdr=False):
517517
"""
518518
Exponentially Damped J-Modulation Apodization
519519
@@ -598,7 +598,7 @@ def jmod(dic, data, off=0.0, j=0.0, lb=0.0, sin=False, cos=False, c=1.0,
598598
end = off + j * (stop - start - 1) / sw
599599
data[..., start:stop] = p.jmod(data[..., start:stop], e, off, end,
600600
inv=inv)
601-
if one == False:
601+
if one is False:
602602
data[..., :start] = 0.0
603603
data[..., stop:] = 0.0
604604

@@ -612,7 +612,7 @@ def jmod(dic, data, off=0.0, j=0.0, lb=0.0, sin=False, cos=False, c=1.0,
612612

613613

614614
def sp(dic, data, off=0.0, end=1.0, pow=1.0, c=1.0, start=1, size='default',
615-
inv=False, one=False, hdr=False):
615+
inv=False, one=False, hdr=False):
616616
"""
617617
Sine bell apodization.
618618
@@ -679,7 +679,7 @@ def sp(dic, data, off=0.0, end=1.0, pow=1.0, c=1.0, start=1, size='default',
679679
stop = start + size
680680
data[..., start:stop] = p.sp(data[..., start:stop], off, end, pow,
681681
inv=inv)
682-
if one == False:
682+
if one is False:
683683
data[..., :start] = 0.0
684684
data[..., stop:] = 0.0
685685

@@ -697,7 +697,7 @@ def sp(dic, data, off=0.0, end=1.0, pow=1.0, c=1.0, start=1, size='default',
697697

698698

699699
def tm(dic, data, t1=0.0, t2=0.0, c=1.0, start=1, size='default', inv=False,
700-
one=False, hdr=False):
700+
one=False, hdr=False):
701701
"""
702702
Trapezoid apodization.
703703
@@ -761,7 +761,7 @@ def tm(dic, data, t1=0.0, t2=0.0, c=1.0, start=1, size='default', inv=False,
761761
stop = start + size
762762
data[..., start:stop] = p.tm(data[..., start:stop], t1=t1, t2=t2,
763763
inv=inv)
764-
if one == False:
764+
if one is False:
765765
data[..., :start] = 0.0
766766
data[..., stop:] = 0.0
767767

@@ -857,7 +857,7 @@ def tri(dic, data, loc="auto", lHi=0.0, rHi=0.0, c=1.0, start=1,
857857
stop = start + size
858858
data[..., start:stop] = p.tri(data[..., start:stop], loc, lHi, rHi,
859859
inv=inv)
860-
if one == False:
860+
if one is False:
861861
data[..., :start] = 0.0
862862
data[..., stop:] = 0.0
863863

@@ -1039,7 +1039,7 @@ def fsh(dic, data, dir, pts, sw=True):
10391039
if dir not in ["ls", "rs"]:
10401040
raise ValueError("dir must be ls or rs")
10411041

1042-
if np.iscomplexobj(data) == False: # real data
1042+
if np.iscomplexobj(data) is False: # real data
10431043
null, data = _ht(dict(dic), data, zf=True)
10441044
del_imag = True
10451045
else: # imaginary data
@@ -1061,7 +1061,7 @@ def fsh(dic, data, dir, pts, sw=True):
10611061
if dic[fn + "FTFLAG"] == 1 and sw: # freq domain
10621062
dic[fn + "CENTER"] = dic[fn + "CENTER"] + pts
10631063
dic = recalc_orig(dic, data, fn)
1064-
if del_imag == False:
1064+
if del_imag is False:
10651065
return dic, data
10661066
else:
10671067
return dic, data.real
@@ -1073,7 +1073,7 @@ def fsh(dic, data, dir, pts, sw=True):
10731073

10741074

10751075
def ft(dic, data, auto=False, real=False, inv=False, alt=False, neg=False,
1076-
null=False, bruk=False):
1076+
null=False, bruk=False):
10771077
"""
10781078
Complex Fourier transform.
10791079
@@ -1131,17 +1131,17 @@ def ft(dic, data, auto=False, real=False, inv=False, alt=False, neg=False,
11311131
# Real, TPPI and Sequential data is real transform
11321132
if dic["FDDIMCOUNT"] >= 2.:
11331133
if (dic["FD2DPHASE"] == 0 or dic["FD2DPHASE"] == 1 and
1134-
fn != "FDF2"):
1135-
real = True
1134+
fn != "FDF2"):
1135+
real = True
11361136

11371137
# sign and negation in AQSIGN
11381138
if dic[fn + "AQSIGN"] == 1 or dic[fn + "AQSIGN"] == 2:
11391139
alt = True
11401140

11411141
if (dic[fn + "AQSIGN"] == 16 or dic[fn + "AQSIGN"] == 17 or
1142-
dic[fn + "AQSIGN"] == 18):
1143-
alt = True
1144-
neg = True
1142+
dic[fn + "AQSIGN"] == 18):
1143+
alt = True
1144+
neg = True
11451145

11461146
# DEBUG
11471147
#print "real:", real
@@ -1160,7 +1160,7 @@ def ft(dic, data, auto=False, real=False, inv=False, alt=False, neg=False,
11601160
data.imag = 0.0
11611161

11621162
if alt: # sign alternate
1163-
if inv == False: # inv with alt, alternates the inverse
1163+
if inv is False: # inv with alt, alternates the inverse
11641164
data[..., 1::2] = data[..., 1::2] * -1.
11651165

11661166
if neg: # negate the imaginary
@@ -1469,7 +1469,7 @@ def ps(dic, data, p0=0.0, p1=0.0, inv=False, hdr=False, noup=False, ht=False,
14691469
else:
14701470
data = p.ps(data, p0=p0, p1=p1, inv=inv)
14711471

1472-
if noup == False:
1472+
if noup is False:
14731473
dic[fn + "P0"] = p0
14741474
dic[fn + "P1"] = p1
14751475

@@ -1522,7 +1522,7 @@ def tp(dic, data, hyper=False, nohyper=False, auto=False, nohdr=False):
15221522
data = np.array(p.tp_hyper(data), dtype="complex64")
15231523
else:
15241524
data = p.tp(data)
1525-
if dic[fn2 + "QUADFLAG"] != 1 and nohyper != True:
1525+
if dic[fn2 + "QUADFLAG"] != 1 and nohyper is not True:
15261526
# unpack complex as needed
15271527
data = np.array(p.c2ri(data), dtype="complex64")
15281528

@@ -1536,7 +1536,7 @@ def tp(dic, data, hyper=False, nohyper=False, auto=False, nohdr=False):
15361536
dic['FDDIMORDER'] = [dic["FDDIMORDER1"], dic["FDDIMORDER2"],
15371537
dic["FDDIMORDER3"], dic["FDDIMORDER4"]]
15381538

1539-
if nohdr != True:
1539+
if nohdr is not True:
15401540
dic["FDTRANSPOSED"] = (dic["FDTRANSPOSED"] + 1) % 2
15411541

15421542
dic = clean_minmax(dic)
@@ -1550,7 +1550,7 @@ def tp(dic, data, hyper=False, nohyper=False, auto=False, nohdr=False):
15501550

15511551

15521552
def zf(dic, data, zf=1, pad="auto", size="auto", mid=False, inter=False,
1553-
auto=False, inv=False):
1553+
auto=False, inv=False):
15541554
"""
15551555
Zero fill
15561556
@@ -1723,7 +1723,7 @@ def cbf(dic, data, last=10, reg=False, slice=slice(None)):
17231723
parameters are not implemented.
17241724
17251725
"""
1726-
if reg != False:
1726+
if reg is not False:
17271727
data = proc_bl.cbf_explicit(data, calc=reg, apply=slice)
17281728
else:
17291729
data = proc_bl.cbf(data, last, slice)
@@ -2234,7 +2234,7 @@ def mir(dic, data, mode="left", invl=False, invr=False, sw=True):
22342234

22352235

22362236
def mult(dic, data, r=1.0, i=1.0, c=1.0, inv=False, hdr=False, x1=1.0,
2237-
xn='default'):
2237+
xn='default'):
22382238
"""
22392239
Multiple by a constant.
22402240
@@ -2498,7 +2498,7 @@ def shuf(dic, data, mode=None):
24982498

24992499

25002500
def sign(dic, data, ri=False, r=False, i=False, left=False, right=False,
2501-
alt=False, abs=False, sign=False):
2501+
alt=False, abs=False, sign=False):
25022502
"""
25032503
Sign manipulation utilities
25042504
@@ -2687,8 +2687,8 @@ def img(dic, data, filter, dx=1.0, dy=1.0, kern=[1], conv=False, thres=None):
26872687
26882688
"""
26892689
# deal with thres by making a masked array
2690-
if thres != None:
2691-
if thres == True:
2690+
if thres is not None:
2691+
if thres is True:
26922692
thres = 0.0 # default value of 0.0
26932693
data = p.thres(data, thres)
26942694

nmrglue/process/proc_lp.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
def lp(data, pred=1, slice=slice(None), order=8, mode="f", append="after",
33-
bad_roots="auto", fix_mode="on", mirror=None, method="svd"):
33+
bad_roots="auto", fix_mode="on", mirror=None, method="svd"):
3434
"""
3535
Linear prediction extrapolation of 1D or 2D data.
3636
@@ -125,7 +125,7 @@ def lp_svd(data, pred=1, slice=slice(None), order=8, mode="f", append="after",
125125

126126

127127
def lp_qr(data, pred=1, slice=slice(None), order=8, mode="f", append="after",
128-
bad_roots="auto", fix_mode="on", mirror=None):
128+
bad_roots="auto", fix_mode="on", mirror=None):
129129
"""
130130
Linear Prediction extrapolation of 1D or 2D data using QR decomposition.
131131
@@ -145,7 +145,7 @@ def lp_cho(data, pred=1, slice=slice(None), order=8, mode="f", append="after",
145145
See :py:func:`lp` for documentation
146146
"""
147147
return lp(data, pred, slice, order, mode, append, bad_roots, fix_mode,
148-
mirror, method="cholesky")
148+
mirror, method="cholesky")
149149

150150

151151
def lp_tls(data, pred=1, slice=slice(None), order=8, mode="f", append="after",
@@ -157,12 +157,12 @@ def lp_tls(data, pred=1, slice=slice(None), order=8, mode="f", append="after",
157157
158158
"""
159159
return lp(data, pred, slice, order, mode, append, bad_roots, fix_mode,
160-
mirror, method="tls")
160+
mirror, method="tls")
161161

162162

163163
# underlying 1D extrapolation
164164
def lp_1d(trace, pred=1, slice=slice(None), order=8, mode="f", append="after",
165-
bad_roots="auto", fix_mode="on", mirror=None, method="svd"):
165+
bad_roots="auto", fix_mode="on", mirror=None, method="svd"):
166166
"""
167167
Linear Prediction extrapolation of 1D data.
168168
@@ -252,7 +252,7 @@ def lp_1d(trace, pred=1, slice=slice(None), order=8, mode="f", append="after",
252252

253253
x = trace[slice] # extract region to use for finding LP coefficients
254254

255-
if mirror != None: # make mirror image if selected
255+
if mirror is not None: # make mirror image if selected
256256
x = make_mirror(x, mirror)
257257

258258
if mode == "fb":
@@ -267,7 +267,7 @@ def lp_1d(trace, pred=1, slice=slice(None), order=8, mode="f", append="after",
267267
a = find_lpc(D, d, method) # determind the LP prediction filter
268268

269269
# stablize roots if needed
270-
if bad_roots != None: # stablize roots if needed
270+
if bad_roots is not None: # stablize roots if needed
271271
poles = find_roots(a, mode) # find roots (poles)
272272
poles = fix_roots(poles, bad_roots, fix_mode) # fix roots
273273
# reverse filter when calculated filter is in wrong direction
@@ -552,7 +552,7 @@ def cadzow_single(x, M, K, min_var=False):
552552

553553

554554
def lp_model(trace, slice=slice(None), order=8, mode="f", mirror=None,
555-
method="svd", full=False):
555+
method="svd", full=False):
556556
"""
557557
Use Linear Prediction to model 1D NMR time domain data.
558558
@@ -612,7 +612,7 @@ def lp_model(trace, slice=slice(None), order=8, mode="f", mirror=None,
612612

613613
x = trace[slice] # extract region to use for finding LP coefficients
614614

615-
if mirror != None: # make mirror image if requested
615+
if mirror is not None: # make mirror image if requested
616616
x = make_mirror(x, mirror)
617617

618618
# calculate LP coefficient and factor to find poles
@@ -634,7 +634,7 @@ def lp_model(trace, slice=slice(None), order=8, mode="f", mirror=None,
634634
damp = [root2damp(pole) for pole in poles]
635635
freq = [root2freq(pole) for pole in poles]
636636

637-
if full == False:
637+
if full is False:
638638
return damp, freq
639639

640640
# perform Least Squares fitting to determind amplitudes and phases.
@@ -887,7 +887,7 @@ def find_lpc_fb(x, order, bad_roots, fix_mode, method):
887887
a = find_lpc(D, d, method)
888888

889889
# stabilize roots if needed
890-
if bad_roots != None:
890+
if bad_roots is not None:
891891
poles = find_roots(a, 'f')
892892
poles = fix_roots(poles, bad_roots, fix_mode)
893893
a = find_coeff(poles, 'f')
@@ -902,7 +902,7 @@ def find_lpc_fb(x, order, bad_roots, fix_mode, method):
902902
poles = find_roots(a, 'b')
903903
poles = [1. / pole for pole in poles]
904904
# stabilize roots if needed
905-
if bad_roots != None:
905+
if bad_roots is not None:
906906
poles = fix_roots(poles, bad_roots, fix_mode)
907907
# find the backward predicted, forward ordered coefficients
908908
backward_a = find_coeff(poles, 'f')
@@ -928,7 +928,7 @@ def find_lpc_bf(x, order, bad_roots, fix_mode, method):
928928
a = find_lpc(D, d, method)
929929

930930
# stabilize roots if needed
931-
if bad_roots != None:
931+
if bad_roots is not None:
932932
poles = find_roots(a, 'b')
933933
poles = fix_roots(poles, bad_roots, fix_mode)
934934
a = find_coeff(poles, 'b')
@@ -943,7 +943,7 @@ def find_lpc_bf(x, order, bad_roots, fix_mode, method):
943943
poles = find_roots(a, 'f')
944944
poles = [1. / pole for pole in poles]
945945
# stabilize roots if needed
946-
if bad_roots != None:
946+
if bad_roots is not None:
947947
poles = fix_roots(poles, bad_roots, fix_mode)
948948
# find the forward predicted, backward ordered coefficients
949949
forward_a = find_coeff(poles, 'b')
@@ -1200,12 +1200,12 @@ def extrapolate(trace, a, pred, append):
12001200
ntrace[:M] = trace
12011201
for i in xrange(pred):
12021202
ntrace[M + i] = np.sum(np.multiply(ntrace[M - m + i:M + i],
1203-
a.flat))
1203+
a.flat))
12041204
return ntrace
12051205

12061206
if append == "before": # append before trace
12071207
ntrace[-M:] = trace
12081208
for i in xrange(pred):
12091209
ntrace[pred - i - 1] = np.sum(np.multiply(
1210-
ntrace[pred - i:pred + m - i], a.flat))
1210+
ntrace[pred - i:pred + m - i], a.flat))
12111211
return ntrace

0 commit comments

Comments
 (0)