Skip to content

Commit

Permalink
Merge pull request #37 from FRBs/slice_bugfix
Browse files Browse the repository at this point in the history
slice_bugfix
pravirkr authored May 10, 2024
2 parents 5f7b897 + 1981e76 commit 090f5bc
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions sigpyproc/readers.py
Original file line number Diff line number Diff line change
@@ -124,8 +124,11 @@ def read_dedisp_block(self, start: int, nsamps: int, dm: float) -> FilterbankBlo
min_sample <= samples_offset,
),
).flatten()
chans_slice = slice(relevant_chans.min(), relevant_chans.max() + 1)

chans_slice = np.arange(
relevant_chans.min(),
relevant_chans.max() + 1,
dtype=int,
)
# Read channel data for for each sample
sample_data = self._file.cread(self.header.nchans)
data[chans_slice, samples_read[chans_slice]] = sample_data[chans_slice]
7 changes: 4 additions & 3 deletions tests/test_readers.py
Original file line number Diff line number Diff line change
@@ -32,11 +32,12 @@ def test_read_block_outofrange(self, filfile_8bit_1: str) -> None:

def test_read_dedisp_block(self, filfile_8bit_1: str) -> None:
fil = FilReader(filfile_8bit_1)
dm = 10
block = fil.read_dedisp_block(0, 100, dm)
dm = 0
block = fil.read_block(0, fil.header.nsamples)
block_dd = fil.read_dedisp_block(0, fil.header.nsamples, dm)
assert isinstance(block, FilterbankBlock)
assert isinstance(block.header, Header)
np.testing.assert_equal(block.dm, dm)
np.testing.assert_equal(block, block_dd)

def test_read_dedisp_block_outofrange(self, filfile_8bit_1: str) -> None:
fil = FilReader(filfile_8bit_1)

0 comments on commit 090f5bc

Please sign in to comment.