From 76b59aa850f0c1e4808fbd49d37ef3bdc23d8453 Mon Sep 17 00:00:00 2001 From: Calum Chamberlain Date: Thu, 11 Aug 2022 10:12:34 +1200 Subject: [PATCH 1/9] Pin pyfftw and scipy Scipy 1.9 changed naming resulting in a break in obspy. pyfftw linking isn't working properly with version 0.13 and our library at the moment. --- recipe/meta.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 7f2ba08..9ab4723 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -34,12 +34,12 @@ requirements: - future - {{ pin_compatible('numpy') }} - fftw - - scipy >=0.18, <1.9.0 + - scipy <1.9.0 - matplotlib-base - obspy - bottleneck - pyproj - - pyfftw + - pyfftw <=0.12 - h5py - llvm-openmp >=4.0.1 # [osx] From 496e1a73d0c6d10d2c1a958e67fe7e65baf09563 Mon Sep 17 00:00:00 2001 From: Calum Chamberlain Date: Thu, 11 Aug 2022 10:12:51 +1200 Subject: [PATCH 2/9] Bump build number --- recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 9ab4723..74dff12 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -15,7 +15,7 @@ source: build: skip: true # [win and py==38] - number: 0 + number: 1 requirements: From e509731811b8cd7bd08337bf042732a37f7ede39 Mon Sep 17 00:00:00 2001 From: Calum Chamberlain Date: Thu, 11 Aug 2022 10:20:07 +1200 Subject: [PATCH 3/9] Require pyfftw at build Ensure that we use the same fftw libraries as pyfftw to avoid linking issues. --- recipe/meta.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 74dff12..d40d903 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -27,6 +27,7 @@ requirements: - future - numpy - fftw + - pyfftw - llvm-openmp >=4.0.1 # [osx] run: - python @@ -39,7 +40,7 @@ requirements: - obspy - bottleneck - pyproj - - pyfftw <=0.12 + - pyfftw - h5py - llvm-openmp >=4.0.1 # [osx] From 846356bf77d7816f9d2ace1eb182c495caad48ed Mon Sep 17 00:00:00 2001 From: Calum Chamberlain Date: Thu, 11 Aug 2022 10:41:22 +1200 Subject: [PATCH 4/9] Add pyfftw call test --- recipe/run_test.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/recipe/run_test.py b/recipe/run_test.py index 5961f1e..4552e0a 100644 --- a/recipe/run_test.py +++ b/recipe/run_test.py @@ -107,6 +107,21 @@ def check_c_locations(): # Load the cdll cdll = libnames._load_cdll("libutils") + +def test_pyfftw_resample(): + import io + from contextlib import redirect_stdout + from eqcorrscan.utils.pre_processing import _resample + + tr = Trace(np.random.randn(360000)) + tr.stats.sampling_rate = 100.0 + + f = io.StringIO() + with redirect_stdout(f): + # If linking not done properly then this will output a traceback to stdout + tr_resampled = _resample(tr, 50, n_threads=2) + assert f.getvalue() == '' + if __name__ == '__main__': """ @@ -114,3 +129,4 @@ def check_c_locations(): """ check_c_locations() test_multi_channel_xcorr() + test_pyfftw_resample() From f9dd3ebb821b4d74c7cab7b89e69e8c28b6e9e24 Mon Sep 17 00:00:00 2001 From: Calum Chamberlain Date: Thu, 11 Aug 2022 10:53:35 +1200 Subject: [PATCH 5/9] Correct arg name --- recipe/run_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/run_test.py b/recipe/run_test.py index 4552e0a..7c8f439 100644 --- a/recipe/run_test.py +++ b/recipe/run_test.py @@ -119,7 +119,7 @@ def test_pyfftw_resample(): f = io.StringIO() with redirect_stdout(f): # If linking not done properly then this will output a traceback to stdout - tr_resampled = _resample(tr, 50, n_threads=2) + tr_resampled = _resample(tr, 50, threads=2) assert f.getvalue() == '' From 612b6ce709c8e747437b26b7df0a3ad244bbdda8 Mon Sep 17 00:00:00 2001 From: Calum Chamberlain Date: Thu, 11 Aug 2022 11:05:29 +1200 Subject: [PATCH 6/9] Pin pyfftw --- recipe/meta.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index d40d903..94ef4cb 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -27,20 +27,20 @@ requirements: - future - numpy - fftw - - pyfftw + - pyfftw ==0.12 - llvm-openmp >=4.0.1 # [osx] run: - python - setuptools - future - {{ pin_compatible('numpy') }} + - pyfftw ==0.12 - fftw - scipy <1.9.0 - matplotlib-base - obspy - bottleneck - pyproj - - pyfftw - h5py - llvm-openmp >=4.0.1 # [osx] From 459998afff0814987fcd631c50d36b8ce267aa6a Mon Sep 17 00:00:00 2001 From: Calum Chamberlain Date: Thu, 11 Aug 2022 11:13:58 +1200 Subject: [PATCH 7/9] Add test for obspy resample --- recipe/run_test.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/recipe/run_test.py b/recipe/run_test.py index 7c8f439..4bd374e 100644 --- a/recipe/run_test.py +++ b/recipe/run_test.py @@ -109,6 +109,7 @@ def check_c_locations(): def test_pyfftw_resample(): + """ Check that pyfftw works properly with our fftw libs. """" import io from contextlib import redirect_stdout from eqcorrscan.utils.pre_processing import _resample @@ -122,6 +123,11 @@ def test_pyfftw_resample(): tr_resampled = _resample(tr, 50, threads=2) assert f.getvalue() == '' +def test_obspy_resample(): + """ Check that obspy resample works - scipy hanning to hann name change. """ + tr = Trace(np.random.randn(360000)) + tr.resample(50) + if __name__ == '__main__': """ From 01d836c9097003f8c95955cf01f39d821c43cf8a Mon Sep 17 00:00:00 2001 From: Calum Chamberlain Date: Thu, 11 Aug 2022 11:17:50 +1200 Subject: [PATCH 8/9] Update run_test.py --- recipe/run_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipe/run_test.py b/recipe/run_test.py index 4bd374e..6ab6943 100644 --- a/recipe/run_test.py +++ b/recipe/run_test.py @@ -136,3 +136,4 @@ def test_obspy_resample(): check_c_locations() test_multi_channel_xcorr() test_pyfftw_resample() + test_obspy_resample() From 4e37eda456d8374f6926752116a6ff9581847e36 Mon Sep 17 00:00:00 2001 From: Calum Chamberlain Date: Thu, 11 Aug 2022 11:23:52 +1200 Subject: [PATCH 9/9] Typo --- recipe/run_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/run_test.py b/recipe/run_test.py index 6ab6943..c26076a 100644 --- a/recipe/run_test.py +++ b/recipe/run_test.py @@ -109,7 +109,7 @@ def check_c_locations(): def test_pyfftw_resample(): - """ Check that pyfftw works properly with our fftw libs. """" + """ Check that pyfftw works properly with our fftw libs. """ import io from contextlib import redirect_stdout from eqcorrscan.utils.pre_processing import _resample