Skip to content

Commit 9ced09e

Browse files
authored
Merge pull request #741 from bashtage/enforce-continuity
BUG: Ensure data is always continguous
2 parents c7de747 + fbee9eb commit 9ced09e

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

arch/tests/univariate/test_mean.py

+13
Original file line numberDiff line numberDiff line change
@@ -1357,3 +1357,16 @@ def test_arch_lm_ar_model(lags):
13571357
val = fit.arch_lm_test()
13581358
assert val.stat > 0
13591359
assert val.pval <= 1
1360+
1361+
1362+
@pytest.mark.parametrize("use_numpy", [True, False])
1363+
def test_non_contiguous_input(use_numpy):
1364+
# GH 740
1365+
if use_numpy:
1366+
y = np.array(SP500, copy=True)[::2]
1367+
assert not y.flags["C_CONTIGUOUS"]
1368+
else:
1369+
y = SP500.iloc[::2]
1370+
mod = arch_model(y, mean="Zero")
1371+
res = mod.fit()
1372+
assert res.params.shape[0] == 3

arch/univariate/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def __init__(
193193
self._y_series = cast(pd.Series, ensure1d(y, "y", series=True))
194194
else:
195195
self._y_series = cast(pd.Series, ensure1d(np.empty((0,)), "y", series=True))
196-
self._y = np.asarray(self._y_series)
196+
self._y = np.ascontiguousarray(self._y_series)
197197
if not np.all(np.isfinite(self._y)):
198198
raise ValueError(
199199
"NaN or inf values found in y. y must contains only finite values."

ci/azure/azure_template_posix.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ jobs:
4848
NUMPY: 1.22.3
4949
SCIPY: 1.8.0
5050
PANDAS: 1.4.0
51-
python_310_no_binary:
52-
python.version: '3.10'
51+
python_311_no_binary:
52+
python.version: '3.11'
5353
ARCH_NO_BINARY: true
5454
PYTEST_OPTS: '--skip-slow'
55-
PANDAS: 1.5.0
55+
PANDAS: 2.2.2
5656
USE_NUMBA: true
5757
python_39_no_binary_environment:
5858
python.version: '3.9'

0 commit comments

Comments
 (0)