You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
import os.path as op
|
|
|
|
import numpy as num
|
|
import pytest
|
|
from lightguide import goldstein, rust
|
|
|
|
|
|
@pytest.fixture
|
|
def data():
|
|
import lightguide
|
|
|
|
das_dir = lightguide.__file__
|
|
return num.load(op.join(op.dirname(das_dir), "data", "data-DAS-gfz2020wswf.npy"))
|
|
|
|
|
|
@pytest.fixture
|
|
def data_big():
|
|
n = 8192
|
|
return num.random.uniform(size=(n, n)).astype(num.float32)
|
|
|
|
|
|
def test_taper():
|
|
window = goldstein.triangular_taper(32, 4)
|
|
assert window[32 // 2, 32 // 2] == 1.0
|
|
assert window.shape == (32, 32)
|
|
|
|
window_rust = rust.triangular_taper(32, 4)
|
|
num.testing.assert_almost_equal(window, window_rust)
|
|
|
|
|
|
# def test_benchmark_goldstein(benchmark, data):
|
|
# benchmark(goldstein.goldstein_filter, data, 32, 14, 0.5)
|
|
|
|
|
|
def test_benchmark_goldstein_rust(benchmark, data_big):
|
|
benchmark(rust.goldstein_filter, data_big, 32, 14, 0.5)
|
|
|
|
|
|
def asdtest_goldstein(data):
|
|
filtered_data = goldstein.goldstein_filter(data, 32, 14, 0.5)
|
|
filtered_data_rust = rust.goldstein_filter(data, 32, 14, 0.5)
|
|
|
|
num.testing.assert_allclose(filtered_data_rust, filtered_data)
|