"""test_strides.py""" from __future__ import annotations import pytest pytest.importorskip("numpy") import numpy as np from strides import main, windows_as_strided, windows_safe def test_safe_windows() -> None: data = np.arange(6) windows = windows_safe(data) assert windows.shape == (4, 3) assert windows.tolist() == [ [0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], ] assert np.shares_memory(windows, data) def test_as_strided_matches() -> None: data = np.arange(6) assert np.array_equal(windows_as_strided(data), windows_safe(data)) def test_main_runs(capsys: pytest.CaptureFixture[str]) -> None: main() out = capsys.readouterr().out assert "shape: (4, 3)" in out assert "shares: True" in out