Skip to content

Commit

Permalink
ENH/BUG: Add check to AR and ARMA instance to prevent bugs
Browse files Browse the repository at this point in the history
Prevent refit except in cases where it does not break results instances
  • Loading branch information
bashtage committed Jul 22, 2019
1 parent af8b5b5 commit 976b009
Show file tree
Hide file tree
Showing 6 changed files with 359 additions and 341 deletions.
2 changes: 2 additions & 0 deletions lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ if [ "$LINT" == true ]; then
statsmodels/tools/tests/test_decorators.py \
statsmodels/tsa/adfvalues.py \
statsmodels/tsa/base/tests/test_datetools.py \
statsmodels/tsa/ar_model.py \
statsmodels/tsa/tests/test_ar.py \
statsmodels/tsa/filters/tests/ \
statsmodels/tsa/innovations/ \
statsmodels/tsa/kalmanf/ \
Expand Down
6 changes: 5 additions & 1 deletion statsmodels/tools/validation/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _right_squeeze(arr, stop_dim=0):


def array_like(obj, name, dtype=np.double, ndim=1, maxdim=None,
shape=None, order='C', contiguous=False):
shape=None, order='C', contiguous=False, optional=False):
"""
Convert array-like to an array and check conditions
Expand Down Expand Up @@ -61,6 +61,8 @@ def array_like(obj, name, dtype=np.double, ndim=1, maxdim=None,
Order of the array
contiguous : bool
Ensure that the array's data is contiguous with order ``order``
optional : bool
Flag indicating whether None is allowed
Examples
--------
Expand Down Expand Up @@ -112,6 +114,8 @@ def array_like(obj, name, dtype=np.double, ndim=1, maxdim=None,
...
ValueError: x is required to have shape (*, 4, 4) but has shape (4, 10, 4)
"""
if optional and obj is None:
return None
arr = np.asarray(obj, dtype=dtype, order=order)
if maxdim is not None:
if arr.ndim > maxdim:
Expand Down
Loading

0 comments on commit 976b009

Please sign in to comment.