Skip to content

Commit

Permalink
Some Python 3 compatibility fixes (#2508)
Browse files Browse the repository at this point in the history
* gaussian.py: minor division fix for Python 3 compatability

* utils.py: move division fixes for Python 3 compatibility
  • Loading branch information
mattpitkin authored and ahnitz committed Feb 19, 2019
1 parent de7f01e commit f59e1d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pycbc/noise/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def noise_from_psd(length, delta_t, psd, seed=None):
randomness = lal.gsl_rng("ranlux", seed)

N = int (1.0 / delta_t / psd.delta_f)
n = N/2+1
stride = N/2
n = N//2+1
stride = N//2

if n > len(psd):
raise ValueError("PSD not compatible with requested delta_t")
Expand Down
12 changes: 6 additions & 6 deletions pycbc/waveform/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,13 @@ def td_taper(out, start, end, beta=8, side='left'):
winlen = 2 * int(width / out.delta_t)
window = Array(signal.get_window(('kaiser', beta), winlen))
xmin = int((start - out.start_time) / out.delta_t)
xmax = xmin + winlen/2
xmax = xmin + winlen//2
if side == 'left':
out[xmin:xmax] *= window[:winlen/2]
out[xmin:xmax] *= window[:winlen//2]
if xmin > 0:
out[:xmin].clear()
elif side == 'right':
out[xmin:xmax] *= window[winlen/2:]
out[xmin:xmax] *= window[winlen//2:]
if xmax < len(out):
out[xmax:].clear()
else:
Expand Down Expand Up @@ -480,12 +480,12 @@ def fd_taper(out, start, end, beta=8, side='left'):
winlen = 2 * int(width / out.delta_f)
window = Array(signal.get_window(('kaiser', beta), winlen))
kmin = int(start / out.delta_f)
kmax = kmin + winlen/2
kmax = kmin + winlen//2
if side == 'left':
out[kmin:kmax] *= window[:winlen/2]
out[kmin:kmax] *= window[:winlen//2]
out[:kmin] *= 0.
elif side == 'right':
out[kmin:kmax] *= window[winlen/2:]
out[kmin:kmax] *= window[winlen//2:]
out[kmax:] *= 0.
else:
raise ValueError("unrecognized side argument {}".format(side))
Expand Down

0 comments on commit f59e1d2

Please # to comment.