Skip to content

Commit 906d646

Browse files
committed
Remove test changes
1 parent f97bafe commit 906d646

File tree

3 files changed

+15
-31
lines changed

3 files changed

+15
-31
lines changed

tests/test_seismic/conftest.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import os
77
import copy
8-
import obspy
98
import pytest
109

1110
from seismic.network_event_dataset import NetworkEventDataset
@@ -55,9 +54,3 @@ def ned_rotation_error(_master_event_dataset, request):
5554
ned.apply(lambda stream: correct_back_azimuth(None, stream, baz_correction=request.param))
5655
ned.param = request.param
5756
return ned
58-
59-
@pytest.fixture(scope='session')
60-
def obspy_stats():
61-
starttime = obspy.UTCDateTime('2020-02-05T15:00:00')
62-
return obspy.core.Stats({'sampling_rate': 10, 'npts': 300, 'inclination': 22,
63-
'starttime': starttime, 'onset': starttime + 5})

tests/test_seismic/test_stream_curation.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@
88
from seismic.stream_quality_filter import curate_stream3c
99

1010

11-
def test_curate_stream(obspy_stats):
11+
def test_curate_stream():
12+
npts = 300
13+
starttime = obspy.UTCDateTime('2020-02-05T15:00:00')
14+
stats = obspy.core.Stats({'sampling_rate': 10, 'npts': npts, 'inclination': 22,
15+
'starttime': starttime, 'onset': starttime + 5})
1216
clean_stream = obspy.Stream()
1317
for channel in ['BHZ', 'BHN', 'BHE']:
14-
obspy_stats.update({'channel': channel})
15-
data = np.random.rand(300)
16-
trace = obspy.Trace(data, obspy_stats)
18+
stats.update({'channel': channel})
19+
data = np.random.rand(npts)
20+
trace = obspy.Trace(data, stats)
1721
assert trace.stats.endtime > trace.stats.starttime
1822
clean_stream += trace
1923
# end for

tests/test_seismic/test_stream_processing.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@
66

77
import numpy as np
88
import obspy
9-
from unittest.mock import MagicMock, patch
10-
import pytest
119

12-
from seismic.stream_processing import zne_order, zrt_order, zerophase_resample
10+
from seismic.stream_processing import zne_order, zrt_order
1311

1412

1513
def test_trace_ordering():
16-
test_stream = obspy.Stream([obspy.Trace(np.random.rand(20)) for _ in range(4)])
14+
test_stream = obspy.Stream([obspy.Trace(np.random.rand(20)) for _ in range(3)])
1715

1816
# Test ZNE ordering
19-
ordered = ('BHZ', 'BHN', 'BHE', 'BHY')
17+
ordered = ('BHZ', 'BHN', 'BHE')
2018
for perm in itertools.permutations(ordered):
2119
for i, tr in enumerate(test_stream):
2220
tr.stats.channel = perm[i]
@@ -26,7 +24,7 @@ def test_trace_ordering():
2624
# end for
2725

2826
# Test ZRT ordering
29-
ordered = ('BHZ', 'BHR', 'BHT', 'BHY')
27+
ordered = ('BHZ', 'BHR', 'BHT')
3028
for perm in itertools.permutations(ordered):
3129
for i, tr in enumerate(test_stream):
3230
tr.stats.channel = perm[i]
@@ -37,18 +35,7 @@ def test_trace_ordering():
3735

3836
# end func
3937

40-
def test_zerophase_resampling_with_invalid_types():
41-
# Test invalid item, not Stream or Trace
42-
with pytest.raises(TypeError):
43-
zerophase_resample(123, 10)
4438

45-
@patch('seismic.stream_processing.lowpass')
46-
def test_zerophase_resampling_success(mocked_lowpass, obspy_stats):
47-
# Test trace gets resampled and lowpass is called if resample_hz < sampling_rate
48-
mocked_resample = MagicMock(spec=obspy.Trace.resample)
49-
mock_trace = MagicMock(spec=obspy.Trace, data=np.array([1,2,3,4]), stats=obspy_stats, resample=mocked_resample)
50-
51-
zerophase_resample(mock_trace, 1)
52-
53-
mocked_resample.assert_called()
54-
mocked_lowpass.assert_called()
39+
if __name__ == "__main__":
40+
test_trace_ordering()
41+
# end if

0 commit comments

Comments
 (0)