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

Skip to content

Commit e4800e7

Browse files
authored
Merge pull request #242 from jiwooseo98/fix_zero_left_shift
bugfix: Fix zero-shift bug in `proc_base.ls`
2 parents da64362 + 725a1a1 commit e4800e7

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

nmrglue/process/proc_base.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def tri(data, loc="auto", lHi=0.0, rHi=0.0, inv=False, rev=False):
324324
###################
325325

326326

327-
def rs(data, pts=0.0):
327+
def rs(data, pts=0):
328328
"""
329329
Right shift and zero fill.
330330
@@ -345,12 +345,13 @@ def rs(data, pts=0.0):
345345
roll : shift without zero filling.
346346
347347
"""
348+
348349
data = np.roll(data, int(pts), axis=-1)
349350
data[..., :int(pts)] = 0
350351
return data
351352

352353

353-
def ls(data, pts=0.0):
354+
def ls(data, pts=0):
354355
"""
355356
Left shift and fill with zero
356357
@@ -371,12 +372,14 @@ def ls(data, pts=0.0):
371372
roll : shift without zero filling.
372373
373374
"""
375+
if int(pts) == 0:
376+
return data
374377
data = np.roll(data, -int(pts), axis=-1)
375378
data[..., -int(pts):] = 0
376379
return data
377380

378381

379-
def cs(data, pts=0.0, neg=False):
382+
def cs(data, pts=0, neg=False):
380383
"""
381384
Circular shift
382385
@@ -399,7 +402,7 @@ def cs(data, pts=0.0, neg=False):
399402
return roll(data, pts, neg)
400403

401404

402-
def roll(data, pts=0.0, neg=False):
405+
def roll(data, pts=0, neg=False):
403406
"""
404407
Roll axis
405408

0 commit comments

Comments
 (0)