Skip to content

Commit 373b70d

Browse files
committed
Fix tests
1 parent f64c8de commit 373b70d

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

dedisperse/dedisperse.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# pylint: disable-msg=C0103
55
import numpy as np
66

7-
def dedisperse(samples, highest_x=None, max_delay=None, dm=None):
7+
def dedisperse(samples, highest_x=None, max_delay=0, dm=None):
88
'''
99
This method performs dedispersion on the filterbank data
1010
The maximum_delay specifies between the currently considered pulsar signal and the next pulsar
@@ -19,22 +19,23 @@ def dedisperse(samples, highest_x=None, max_delay=None, dm=None):
1919
pulsar_intensity = find_estimation_intensity(samples, highest_x)
2020
dm = find_dm(samples, pulsar_intensity, max_delay)
2121

22-
# Distribute the DM over the amount of samples
23-
delays_per_sample = np.round(np.linspace(dm, 0, samples.shape[1])).astype(int)
22+
if dm:
23+
# Distribute the DM over the amount of samples
24+
delays_per_sample = (np.round(np.linspace(dm, 0, samples.shape[1]))).astype(int)
2425

25-
# Loop over the frequencies
26-
for i, _ in enumerate(delays_per_sample):
26+
# Loop over the frequencies
27+
for i, _ in enumerate(delays_per_sample):
2728

28-
# Temporary array that is used to later delay the frequency
29-
temporary_samples = []
29+
# Temporary array that is used to later delay the frequency
30+
temporary_samples = []
3031

31-
# Select frequency/column 'i' of all samples
32-
temporary_samples = samples[:, i]
32+
# Select frequency/column 'i' of all samples
33+
temporary_samples = samples[:, i]
3334

34-
# Write back the frequency/column 'i' to the samples, using numpy's roll function
35-
samples[:, i] = np.roll(temporary_samples, delays_per_sample[i])
35+
# Write back the frequency/column 'i' to the samples, using numpy's roll function
36+
samples[:, i] = np.roll(temporary_samples, delays_per_sample[i])
3637

37-
return samples
38+
return samples
3839

3940
def find_dm(samples, pulsar_intensity, max_delay):
4041
'''

examples/dedisperse_stream.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import dedisperse as dedisperse
1515
from plot.static_waterfall import waterfall_plot
1616

17-
from timeseries.timeseries import Timeseries
18-
1917
from clipping import clipping
2018

2119
# Read filterbank data,

tests/test_dedisperse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import unittest
6+
import numpy as np
67

78
from .context import dedisperse # pylint: disable-msg=E0611
89

@@ -25,5 +26,5 @@ def test_dedisperse(self):
2526
expect moved frequencies per sample
2627
"""
2728
disp_measure = 6
28-
results = dedisperse.dedisperse(self.samples, disp_measure)
29+
results = dedisperse.dedisperse(np.array(self.samples), None, None, disp_measure)
2930
self.assertListEqual(list(results[len(self.samples)-1]), [10]*7)

0 commit comments

Comments
 (0)