Skip to content

Commit 5f6d097

Browse files
committed
Simplify invalid type zerophase resampling test
1 parent ed6f65f commit 5f6d097

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

seismic/ml_classifier/data_harvester/process-traces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def genTS(net,st,ch,loc,ptime,stime):
105105
stime=UTCDateTime(*(stimeint+[smsec]))
106106
#get a waveform to train against
107107
wf=genTS(net,st,chan,loc,ptime,stime)
108-
if not(wf is None) and len(wf)>100:#discard bad or short waveforms extracted from the database
108+
if not(wf is None) and len(wf)>100:#discard bad or short waveforms extracted from the database
109109
wfctr+=1
110110
#resample the waveforms to 1000 points, detrend and normalise. The extra 0.01 ensures that the resulting trace
111111
#does in fact have 1000 points

tests/test_seismic/test_stream_processing.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import numpy as np
88
import obspy
99
from unittest.mock import MagicMock, patch
10+
import pytest
1011

1112
from seismic.stream_processing import zne_order, zrt_order, zerophase_resample
1213

@@ -38,12 +39,8 @@ def test_trace_ordering():
3839

3940
def test_zerophase_resampling_with_invalid_types():
4041
# Test invalid item, not Stream or Trace
41-
try:
42+
with pytest.raises(TypeError):
4243
zerophase_resample(123, 10)
43-
except TypeError:
44-
pass
45-
else:
46-
raise AssertionError("Expected TypeError for invalid item type")
4744

4845
@patch('seismic.stream_processing.lowpass')
4946
def test_zerophase_resampling_success(mocked_lowpass, obspy_stats):

0 commit comments

Comments
 (0)