Skip to content

Commit 35ad591

Browse files
BUG: signal: correlation_lags, fail with meaningful error message if the mode is unknown (scipy#21808)
1 parent b145dfa commit 35ad591

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

scipy/signal/_signaltools.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ def correlation_lags(in1_len, in2_len, mode='full'):
405405
lags = np.arange(lag_bound + 1)
406406
else:
407407
lags = np.arange(lag_bound, 1)
408+
else:
409+
raise ValueError(f"Mode {mode} is invalid")
408410
return lags
409411

410412

scipy/signal/tests/test_signaltools.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,6 +2135,11 @@ def test_correlation_lags(mode, behind, input_size):
21352135
assert_equal(lags.shape, correlation.shape)
21362136

21372137

2138+
def test_correlation_lags_invalid_mode():
2139+
with pytest.raises(ValueError, match="Mode asdfgh is invalid"):
2140+
correlation_lags(100, 100, mode="asdfgh")
2141+
2142+
21382143
@pytest.mark.parametrize('dt', [np.csingle, np.cdouble,
21392144
pytest.param(np.clongdouble, marks=_pmf)])
21402145
class TestCorrelateComplex:

0 commit comments

Comments
 (0)