Skip to content

Commit 985cb68

Browse files
committed
Test zerophase resampling when resample_hz < sampling rate
1 parent 36086fd commit 985cb68

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

.github/workflows/hiperseis_main_ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
eval "$(conda shell.bash hook)"
4343
conda init
4444
conda activate hiperseis
45-
coverage run -m pytest tests
45+
coverage run -m pytest tests/test_seismic/test_stream_processing.py
4646
coverage xml
4747
- name: Upload coverage reports to Codecov
4848
uses: codecov/codecov-action@main

seismic/stream_processing.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44

55
import copy
66
import functools
7-
import logging
87
import numbers
98
import json
10-
import os
11-
from collections import defaultdict
129
from obspy.signal.filter import lowpass
1310
from obspy.core import Stream, Trace
1411

tests/test_seismic/test_stream_processing.py

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

77
import numpy as np
88
import obspy
9-
from unittest.mock import MagicMock
9+
from unittest.mock import MagicMock, patch
1010

1111
from seismic.stream_processing import zne_order, zrt_order, zerophase_resample
1212

@@ -45,11 +45,13 @@ def test_zerophase_resampling_with_invalid_types():
4545
else:
4646
raise AssertionError("Expected TypeError for invalid item type")
4747

48-
def test_zerophase_resampling_success(obspy_stats):
49-
# Test resampling trace
48+
@patch('seismic.stream_processing.lowpass')
49+
def test_zerophase_resampling_success(mocked_lowpass, obspy_stats):
50+
# Test trace gets resampled and lowpass is called if resample_hz < sampling_rate
5051
mocked_resample = MagicMock(spec=obspy.Trace.resample)
51-
mock_trace = MagicMock(spec=obspy.Trace, data=np.arange(4), stats=obspy_stats, resample=mocked_resample)
52+
mock_trace = MagicMock(spec=obspy.Trace, data=np.array([1,2,3,4]), stats=obspy_stats, resample=mocked_resample)
5253

53-
zerophase_resample(mock_trace, 10)
54+
zerophase_resample(mock_trace, 1)
5455

5556
mocked_resample.assert_called()
57+
mocked_lowpass.assert_called()

0 commit comments

Comments
 (0)