Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Ensure data is always continguous #741

Merged
merged 3 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading