Skip to content

Commit

Permalink
Test and fix #592
Browse files Browse the repository at this point in the history
  • Loading branch information
calum-chamberlain committed Dec 5, 2024
1 parent b9c7374 commit 8f39862
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
25 changes: 25 additions & 0 deletions eqcorrscan/tests/pre_processing_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,31 @@ def test_process_bad_data(self):
filt_order=3, samp_rate=1, starttime=False,
seisan_chan_names=True, ignore_length=False)

def test_process_partial_bad_data(self):
"""

Check failure on line 273 in eqcorrscan/tests/pre_processing_test.py

View workflow job for this annotation

GitHub Actions / flake8-linter

W291 trailing whitespace
Check that processing works as expected when we have

Check failure on line 274 in eqcorrscan/tests/pre_processing_test.py

View workflow job for this annotation

GitHub Actions / flake8-linter

W291 trailing whitespace
partial bad data. Issue #592

Check failure on line 275 in eqcorrscan/tests/pre_processing_test.py

View workflow job for this annotation

GitHub Actions / flake8-linter

W291 trailing whitespace
"""
bad_data = Stream([self.st[0].slice(
self.st[0].stats.starttime,

Check failure on line 278 in eqcorrscan/tests/pre_processing_test.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E126 continuation line over-indented for hanging indent

Check failure on line 278 in eqcorrscan/tests/pre_processing_test.py

View workflow job for this annotation

GitHub Actions / flake8-linter

W291 trailing whitespace
self.st[0].stats.starttime + 20).copy()])
bad_data += self.st[1].copy()
with self.assertRaises(NotImplementedError):
multi_process(
st=bad_data, lowcut=0.1, highcut=0.4,
filt_order=3, samp_rate=1,

Check failure on line 284 in eqcorrscan/tests/pre_processing_test.py

View workflow job for this annotation

GitHub Actions / flake8-linter

W291 trailing whitespace
starttime=bad_data[1].stats.starttime,
endtime=bad_data[1].stats.endtime,
seisan_chan_names=True, ignore_length=False)
# Check that it just drops that trace with ignore_bad_data
st_processed = multi_process(
st=bad_data, lowcut=0.1, highcut=0.4,
filt_order=3, samp_rate=1,
starttime=bad_data[1].stats.starttime,
endtime=bad_data[1].stats.endtime,
seisan_chan_names=True, ignore_bad_data=True)
self.assertEqual(len(st_processed), 1)

def test_short_data_fail(self):
"""Check that we don't allow too much missing data."""
with self.assertRaises(NotImplementedError):
Expand Down
5 changes: 4 additions & 1 deletion eqcorrscan/utils/pre_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,10 @@ def multi_process(st, lowcut, highcut, filt_order, samp_rate, parallel=False,
# Check that we actually still have some data
if not _stream_has_data(st):
if tracein:
return st[0]
if len(st):
return st[0]

Check warning on line 305 in eqcorrscan/utils/pre_processing.py

View check run for this annotation

Codecov / codecov/patch

eqcorrscan/utils/pre_processing.py#L305

Added line #L305 was not covered by tests
else:
return Trace()
return st

Logger.info(f"Stream after length check and padding is: {st}")
Expand Down

0 comments on commit 8f39862

Please sign in to comment.