Skip to content

Commit

Permalink
test/refactor: included power failure into wrong input test of nois…
Browse files Browse the repository at this point in the history
…e estimation; restructured reference finite difference kernels
  • Loading branch information
MothNik committed May 20, 2024
1 parent dd4cc7a commit 77b9f6e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
6 changes: 5 additions & 1 deletion tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ def noise_level_whittaker_auto_lambda() -> np.ndarray:

@pytest.fixture
def reference_forward_finite_differences() -> List[RefDifferenceKernel]:
fpath = os.path.join(
path_to_resources,
"./finite_differences/reference_forward_differences.csv",
)
fin_diff_table = np.genfromtxt(
os.path.join(path_to_resources, "reference_finite_differences.csv"),
fpath,
skip_header=2,
delimiter=",",
filling_values=np.nan,
Expand Down
42 changes: 38 additions & 4 deletions tests/test_for_utils/test_finite_differences.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,111 +152,142 @@ def test_squ_fw_fin_diff_mat_cho_banded_transpose_first(


@pytest.mark.parametrize(
"series, differences, accuracy, window_size, stddev_min",
"series, differences, accuracy, window_size, power, stddev_min",
[
( # Number 0 series is too small for difference kernel
np.arange(start=0, stop=5),
10,
2,
3,
1,
1e-10,
),
( # Number 1 series is too small for difference kernel
np.arange(start=0, stop=5),
10,
2,
None,
1,
1e-10,
),
( # Number 2 series is too small for window size
np.arange(start=0, stop=5),
1,
2,
11,
1,
1e-10,
),
( # Number 3 the difference order is 0
np.arange(start=0, stop=10),
0,
2,
3,
1,
1e-10,
),
( # Number 4 the difference order is negative
np.arange(start=0, stop=10),
-1,
2,
3,
1,
1e-10,
),
( # Number 5 the accuracy is odd
np.arange(start=0, stop=10),
2,
3,
3,
1,
1e-10,
),
( # Number 6 the accuracy is odd
np.arange(start=0, stop=10),
2,
5,
3,
1,
1e-10,
),
( # Number 7 the accuracy is 1
np.arange(start=0, stop=10),
2,
1,
3,
1,
1e-10,
),
( # Number 8 the accuracy is 0
np.arange(start=0, stop=10),
2,
0,
3,
1,
1e-10,
),
( # Number 9 the accuracy is negative
np.arange(start=0, stop=10),
2,
-1,
3,
1,
1e-10,
),
( # Number 10 the window size is even
np.arange(start=0, stop=10),
1,
2,
6,
1,
1e-10,
),
( # Number 11 the window size is 0
np.arange(start=0, stop=10),
1,
2,
0,
1,
1e-10,
),
( # Number 12 the window size is negative
np.arange(start=0, stop=10),
1,
2,
-1,
1,
1e-10,
),
( # Number 13 the power is -3
np.arange(start=0, stop=10),
1,
2,
3,
-3,
1e-10,
),
( # Number 14 the power is 3
np.arange(start=0, stop=10),
1,
2,
3,
3,
1e-10,
),
( # Number 13 the minimum standard deviation is zero
( # Number 15 the minimum standard deviation is zero
np.arange(start=0, stop=5),
1,
2,
3,
1,
0.0,
),
( # Number 14 the minimum standard deviation is negative
( # Number 16 the minimum standard deviation is negative
np.arange(start=0, stop=5),
1,
2,
3,
1,
-10.0,
),
],
Expand All @@ -266,6 +297,7 @@ def test_estimate_noise_stddev_invalid_input(
differences: int,
accuracy: int,
window_size: Optional[int],
power: int,
stddev_min: float,
) -> None:
"""
Expand All @@ -276,7 +308,8 @@ def test_estimate_noise_stddev_invalid_input(
- the series length,
- the difference order,
- the accuracy,
- the window size, and
- the window size,
- the power to which the noise level is raised, and
- the minimum standard deviation
are chosen such that the input is invalid.
Expand All @@ -289,6 +322,7 @@ def test_estimate_noise_stddev_invalid_input(
differences=differences,
diff_accuracy=accuracy,
window_size=window_size,
power=power, # type: ignore
stddev_min=stddev_min,
)

Expand Down

0 comments on commit 77b9f6e

Please sign in to comment.