Skip to content

Commit

Permalink
REF: use FutureWarning for unknown kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
ChadFulton committed Apr 20, 2023
1 parent b24f265 commit f4ebf1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions statsmodels/tsa/statespace/representation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
License: Simplified-BSD
"""

import warnings
import numpy as np
from .tools import (
find_best_blas_type, validate_matrix_shape, validate_vector_shape
Expand Down Expand Up @@ -365,8 +366,12 @@ def __init__(self, k_endog, k_states, k_posdef=None,

# Check for unused kwargs
if len(kwargs):
raise TypeError(f'{__class__} constructor got unexpected keyword'
f' argument(s): {kwargs}.')
# raise TypeError(f'{__class__} constructor got unexpected keyword'
# f' argument(s): {kwargs}.')
msg = (f'Unknown keyword arguments: {kwargs.keys()}.'
'Passing unknown keyword arguments will raise a TypeError'
' beginning in version 0.15.')
warnings.warn(msg, FutureWarning)


# Matrix representations storage
Expand Down
8 changes: 6 additions & 2 deletions statsmodels/tsa/statespace/tests/test_mlemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,5 +1231,9 @@ def test_invalid_kwargs():
endog = [0, 0, 1.]
# Make sure we can create basic SARIMAX
sarimax.SARIMAX(endog)
# Now check that it raises an error if we add an invalid keyword argument
assert_raises(TypeError, sarimax.SARIMAX, endog, invalid_kwarg=True)
# Now check that it raises a warning if we add an invalid keyword argument
with pytest.warns(FutureWarning):
sarimax.SARIMAX(endog, invalid_kwarg=True)
# (Note: once deprectation is completed in v0.15, switch to checking for
# a TypeError, as below)
# assert_raises(TypeError, sarimax.SARIMAX, endog, invalid_kwarg=True)

0 comments on commit f4ebf1c

Please sign in to comment.