Skip to content

Commit

Permalink
Merge pull request #741 from bashtage/enforce-continuity
Browse files Browse the repository at this point in the history
BUG: Ensure data is always continguous
  • Loading branch information
bashtage authored Jul 27, 2024
2 parents c7de747 + fbee9eb commit 9ced09e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
13 changes: 13 additions & 0 deletions arch/tests/univariate/test_mean.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,3 +1357,16 @@ def test_arch_lm_ar_model(lags):
val = fit.arch_lm_test()
assert val.stat > 0
assert val.pval <= 1


@pytest.mark.parametrize("use_numpy", [True, False])
def test_non_contiguous_input(use_numpy):
# GH 740
if use_numpy:
y = np.array(SP500, copy=True)[::2]
assert not y.flags["C_CONTIGUOUS"]
else:
y = SP500.iloc[::2]
mod = arch_model(y, mean="Zero")
res = mod.fit()
assert res.params.shape[0] == 3
2 changes: 1 addition & 1 deletion arch/univariate/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def __init__(
self._y_series = cast(pd.Series, ensure1d(y, "y", series=True))
else:
self._y_series = cast(pd.Series, ensure1d(np.empty((0,)), "y", series=True))
self._y = np.asarray(self._y_series)
self._y = np.ascontiguousarray(self._y_series)
if not np.all(np.isfinite(self._y)):
raise ValueError(
"NaN or inf values found in y. y must contains only finite values."
Expand Down
6 changes: 3 additions & 3 deletions ci/azure/azure_template_posix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ jobs:
NUMPY: 1.22.3
SCIPY: 1.8.0
PANDAS: 1.4.0
python_310_no_binary:
python.version: '3.10'
python_311_no_binary:
python.version: '3.11'
ARCH_NO_BINARY: true
PYTEST_OPTS: '--skip-slow'
PANDAS: 1.5.0
PANDAS: 2.2.2
USE_NUMBA: true
python_39_no_binary_environment:
python.version: '3.9'
Expand Down

0 comments on commit 9ced09e

Please sign in to comment.