Skip to content

Commit

Permalink
Change the adaptive hfilt test to make Travis happy.
Browse files Browse the repository at this point in the history
  • Loading branch information
benhills committed Oct 23, 2020
1 parent 8145a60 commit 0542f4f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion impdar/bin/impproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def hfilt(dat, start_trace=0, end_trace=-1, **kwargs):

def ahfilt(dat, window_size=1000, **kwargs):
"""Adaptive horizontal filter."""
dat.hfilt(ftype='adaptive', window_size=1000)
dat.hfilt(ftype='adaptive', window_size=window_size)


def rev(dat, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion impdar/lib/RadarData/_RadarDataFiltering.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ..ImpdarError import ImpdarError


def adaptivehfilt(self, window_size=1000, *args, **kwargs):
def adaptivehfilt(self, window_size, *args, **kwargs):
"""Adaptively filter to reduce noise in upper layers
This subtracts the average of traces around an individual trace in order to filter it.
Expand Down
4 changes: 2 additions & 2 deletions impdar/lib/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def process_and_exit(fn, cat=False, filetype='mat', **kwargs):


def process(RadarDataList, interp=None, rev=False, vbp=None, hfilt=None,
ahfilt=False, nmo=None, crop=None, hcrop=None, restack=None,
ahfilt=None, nmo=None, crop=None, hcrop=None, restack=None,
denoise=None, migrate=None, **kwargs):
"""Perform one or more processing steps on a list of RadarData .
Expand Down Expand Up @@ -158,7 +158,7 @@ def process(RadarDataList, interp=None, rev=False, vbp=None, hfilt=None,

if ahfilt:
for dat in RadarDataList:
dat.hfilt(ftype='adaptive')
dat.hfilt(ftype='adaptive',window_size=ahfilt)
done_stuff = True

if nmo is not None:
Expand Down
9 changes: 5 additions & 4 deletions impdar/tests/test_RadarDataFiltering.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ class TestRadarDataHfiltWrapper(unittest.TestCase):
def test_adaptive(self):
radardata = NoInitRadarData()
radardata.adaptivehfilt = MagicMock()
radardata.hfilt(ftype='adaptive')
radardata.adaptivehfilt.assert_called_with()
radardata.hfilt(ftype='adaptive', window_size=1000)
radardata.adaptivehfilt.assert_called_with(window_size=1000)

def test_horizontalfilt(self):
radardata = NoInitRadarData()
Expand All @@ -267,11 +267,12 @@ def test_badfilter(self):


class TestProcessWrapper(unittest.TestCase):

def test_process_ahfilt(self):
radardata = NoInitRadarData()
radardata.adaptivehfilt = MagicMock()
process.process([radardata], ahfilt=True)
radardata.adaptivehfilt.assert_called_with()
process.process([radardata], ahfilt=1000)
radardata.adaptivehfilt.assert_called_with(window_size=1000)

def test_process_hfilt(self):
radardata = NoInitRadarData()
Expand Down
2 changes: 1 addition & 1 deletion impdar/tests/test_impproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_rev(self, load_patch, rev_patch):
@patch('impdar.bin.impproc.load')
def test_ahfilt(self, load_patch, ahfilt_patch):
load_patch.return_value = [MagicMock()]
impproc.sys.argv = ['dummy', 'ahfilt', 'dummy.mat']
impproc.sys.argv = ['dummy', 'ahfilt', '1000', 'dummy.mat']
impproc.main()
self.assertTrue(ahfilt_patch.called)

Expand Down

0 comments on commit 0542f4f

Please sign in to comment.