From d96ef51322b34609d0eece9b0728e148b9d54907 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 16 Apr 2024 09:44:09 +0100 Subject: [PATCH 1/2] ENH: Add support for NumPy 3 Add build support for NumPy 2 --- arch/tests/bootstrap/test_bootstrap.py | 2 +- arch/tests/univariate/test_arch_in_mean.py | 2 +- arch/typing.py | 6 ++--- .../phillips-ouliaris-simulation-process.py | 2 +- arch/unitroot/unitroot.py | 4 +-- arch/utility/array.py | 6 ++--- arch/utility/timeseries.py | 9 +++---- ci/azure/azure_template_posix.yml | 25 +++++++++---------- ci/azure/install-posix.sh | 2 +- pyproject.toml | 7 +++--- requirements-dev.txt | 7 +++--- requirements.txt | 6 ++--- 12 files changed, 34 insertions(+), 44 deletions(-) diff --git a/arch/tests/bootstrap/test_bootstrap.py b/arch/tests/bootstrap/test_bootstrap.py index 6f788fd5af..836b1bbbf9 100644 --- a/arch/tests/bootstrap/test_bootstrap.py +++ b/arch/tests/bootstrap/test_bootstrap.py @@ -538,7 +538,7 @@ def test_jackknife(bs_setup): x = bs_setup.x_df results_df = _loo_jackknife(bs_setup.func, len(x), (x,), {}) - assert_equal(results, results_df) + assert_allclose(results, results_df) y = bs_setup.y results = _loo_jackknife(bs_setup.func, len(y), (y,), {}) diff --git a/arch/tests/univariate/test_arch_in_mean.py b/arch/tests/univariate/test_arch_in_mean.py index 7e69ab5b2a..d160d2bf72 100644 --- a/arch/tests/univariate/test_arch_in_mean.py +++ b/arch/tests/univariate/test_arch_in_mean.py @@ -17,7 +17,7 @@ SP500 = 100 * sp500.load()["Adj Close"].pct_change().dropna() SP500 = SP500.iloc[SP500.shape[0] // 2 :] -X = pd.concat([SP500, SP500], axis=1, copy=True) +X = pd.concat([SP500, SP500], axis=1) X.columns = pd.Index([0, 1]) RANDOMSTATE = np.random.RandomState(12349876) X.loc[:, :] = RANDOMSTATE.standard_normal(X.shape) diff --git a/arch/typing.py b/arch/typing.py index 35fc3f609f..d76f84ab36 100644 --- a/arch/typing.py +++ b/arch/typing.py @@ -45,9 +45,9 @@ AnyArray = np.ndarray[Any, Any] # pragma: no cover Uint32Array = np.ndarray[Any, np.dtype[np.uint32]] # pragma: no cover else: - Uint32Array = ( - IntArray - ) = Float64Array = Int64Array = Int32Array = BoolArray = AnyArray = NDArray + Uint32Array = IntArray = Float64Array = Int64Array = Int32Array = BoolArray = ( + AnyArray + ) = NDArray BootstrapIndexT = Union[ Int64Array, tuple[Int64Array, ...], tuple[list[Int64Array], dict[str, Int64Array]] diff --git a/arch/unitroot/critical_values/simulation/phillips-ouliaris-simulation-process.py b/arch/unitroot/critical_values/simulation/phillips-ouliaris-simulation-process.py index 6140ecae73..ea3cc1b900 100644 --- a/arch/unitroot/critical_values/simulation/phillips-ouliaris-simulation-process.py +++ b/arch/unitroot/critical_values/simulation/phillips-ouliaris-simulation-process.py @@ -20,7 +20,7 @@ META = {"z_a": "negative", "z_t": "negative", "p_u": "positive", "p_z": "positive"} CRITICAL_VALUES = (1, 5, 10) PLOT = False -WINS: dict[int, int] = defaultdict(lambda: 0) +WINS: dict[int, int] = defaultdict(int) # 1. Load data # 2. Compute critical values diff --git a/arch/unitroot/unitroot.py b/arch/unitroot/unitroot.py index f58ac98025..80c21851f4 100644 --- a/arch/unitroot/unitroot.py +++ b/arch/unitroot/unitroot.py @@ -1144,9 +1144,7 @@ def _compute_statistic(self) -> None: self._stat_tau = sqrt(gamma0 / lam2) * ((rho - 1) / sigma) - 0.5 * ( (lam2 - gamma0) / lam ) * (n * sigma / s) - self._stat_rho = n * (rho - 1) - 0.5 * (n**2.0 * sigma2 / s2) * ( - lam2 - gamma0 - ) + self._stat_rho = n * (rho - 1) - 0.5 * (n**2.0 * sigma2 / s2) * (lam2 - gamma0) self._nobs = int(resols.nobs) if self._test_type == "rho": diff --git a/arch/utility/array.py b/arch/utility/array.py index 45e18f5396..df6fc35a8a 100644 --- a/arch/utility/array.py +++ b/arch/utility/array.py @@ -38,8 +38,7 @@ def ensure1d( x: int | float | Sequence[int | float] | ArrayLike, name: Hashable | None, series: Literal[True] = ..., -) -> Series: - ... # pragma: no cover +) -> Series: ... # pragma: no cover @overload @@ -47,8 +46,7 @@ def ensure1d( x: int | float | Sequence[int | float] | ArrayLike, name: Hashable | None, series: Literal[False], -) -> np.ndarray: - ... # pragma: no cover +) -> np.ndarray: ... # pragma: no cover def ensure1d( diff --git a/arch/utility/timeseries.py b/arch/utility/timeseries.py index 8af0b9655f..477e32df89 100644 --- a/arch/utility/timeseries.py +++ b/arch/utility/timeseries.py @@ -48,8 +48,7 @@ def add_trend( prepend: bool = ..., nobs: int = ..., has_constant: Literal["raise", "add", "skip"] = ..., -) -> Float64Array: - ... # pragma: no cover +) -> Float64Array: ... # pragma: no cover @overload @@ -59,8 +58,7 @@ def add_trend( prepend: bool = ..., nobs: None = ..., has_constant: Literal["raise", "add", "skip"] = ..., -) -> Float64Array: - ... # pragma: no cover +) -> Float64Array: ... # pragma: no cover @overload @@ -70,8 +68,7 @@ def add_trend( prepend: bool = ..., nobs: None = ..., has_constant: Literal["raise", "add", "skip"] = ..., -) -> pd.DataFrame: - ... # pragma: no cover +) -> pd.DataFrame: ... # pragma: no cover def add_trend( diff --git a/ci/azure/azure_template_posix.yml b/ci/azure/azure_template_posix.yml index f75e237785..b6a4bb1eac 100644 --- a/ci/azure/azure_template_posix.yml +++ b/ci/azure/azure_template_posix.yml @@ -45,14 +45,14 @@ jobs: python39_numpy120: python.version: '3.9' MATPLOTLIB: 3.3.0 - NUMPY: 1.20.0 - SCIPY: 1.7.0 - PANDAS: 1.2.0 + NUMPY: 1.22.3 + SCIPY: 1.8.0 + PANDAS: 1.4.0 python_310_no_binary: python.version: '3.10' ARCH_NO_BINARY: true PYTEST_OPTS: '--skip-slow' - PANDAS: 1.4.0 + PANDAS: 1.5.0 USE_NUMBA: true python_39_no_binary_environment: python.version: '3.9' @@ -62,22 +62,22 @@ jobs: PYTEST_OPTS: '--skip-slow' python_39_no_numba: python.version: '3.9' - NUMPY: 1.21.0 + NUMPY: 1.24.0 USE_NUMBA: false - MATPLOTLIB: 3.3.0 + MATPLOTLIB: 3.5.0 PANDAS: 1.5.0 PYTEST_PATTERN: "(slow or not slow)" python_39_numpy_118: python.version: '3.9' - NUMPY: 1.22.0 + NUMPY: 1.24.0 USE_NUMBA: false PYTEST_PATTERN: "(slow or not slow)" python_minimums: python.version: '3.9' - NUMPY: 1.19.0 - SCIPY: 1.5.0 - MATPLOTLIB: 3.3.0 - PANDAS: 1.1.0 + NUMPY: 1.23.0 + SCIPY: 1.9.0 + MATPLOTLIB: 3.4.0 + PANDAS: 1.4.0 python312_pre: python.version: '3.12' pip.pre: true @@ -176,9 +176,8 @@ jobs: testRunTitle: 'Python $(python.version)' condition: succeededOrFailed() - - task: PublishCodeCoverageResults@1 + - task: PublishCodeCoverageResults@2 inputs: - codeCoverageTool: Cobertura summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' condition: and(eq(variables['coverage'], 'true'), ne(variables['test.install'], 'true')) diff --git a/ci/azure/install-posix.sh b/ci/azure/install-posix.sh index 4d50558900..bd0eb70a76 100644 --- a/ci/azure/install-posix.sh +++ b/ci/azure/install-posix.sh @@ -16,7 +16,7 @@ else fi python -m pip install --upgrade pip "setuptools>=61" wheel -python -m pip install cython "pytest>=7" pytest-xdist coverage pytest-cov ipython jupyter notebook nbconvert "property_cached>=1.6.3" black isort flake8 nbconvert setuptools_scm colorama +python -m pip install cython "pytest>=7,<8" pytest-xdist coverage pytest-cov ipython jupyter notebook nbconvert "property_cached>=1.6.3" black isort flake8 nbconvert setuptools_scm colorama if [[ -n ${NUMPY} ]]; then CMD="$CMD~=${NUMPY}"; fi; CMD="$CMD scipy" diff --git a/pyproject.toml b/pyproject.toml index 6434a65a16..d36f5a07e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,9 +55,8 @@ requires = [ "setuptools>=61", "wheel", "setuptools_scm[toml]>=8.0.3,<9", - "oldest-supported-numpy>=2022.11.19", - "cython>=0.29.34", # Works with 3.0.0b2 - + "cython>=3.0.10", + "numpy>=2.0.0rc1,<3" ] build-backend = "setuptools.build_meta" @@ -65,7 +64,7 @@ build-backend = "setuptools.build_meta" dependencies = { file = ["requirements.txt"] } [tool.black] -target-version = ['py39', 'py310', 'py311'] +target-version = ['py39', 'py310', 'py311', 'py312'] exclude = ''' ( \.egg diff --git a/requirements-dev.txt b/requirements-dev.txt index 9fd0fc3d34..680b465a3f 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,10 +1,9 @@ # versioning setuptools_scm[toml]>=8.0.3,<9 packaging -oldest-supported-numpy>=2022.11.19 # Performance -cython>=0.29.34 # Works with 3.0.0b2 +cython>=3.0.10 numba>=0.49,!=0.50.*;python_version<"3.12" # Graphics @@ -12,12 +11,12 @@ matplotlib>=3 seaborn # Tests -pytest>=7.3 +pytest>=7.3,<8 pytest-xdist pytest-cov # formatting -black[jupyter]==23.12.1 +black[jupyter]~=24.4.0 isort~=5.0 colorama flake8 diff --git a/requirements.txt b/requirements.txt index e1f566f66f..f092686722 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy>=1.19 -scipy>=1.5 -pandas>=1.1 +numpy>=1.22.3 +scipy>=1.8 +pandas>=1.4 statsmodels>=0.12 From 015e3a5d5a8c567a04c1915fd8a49a98d4410fdb Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 16 Apr 2024 10:43:17 +0100 Subject: [PATCH 2/2] STYL: Fix linting issues --- appveyor.yml | 33 --------------------------------- arch/utility/array.py | 6 ++++-- arch/utility/timeseries.py | 9 ++++++--- 3 files changed, 10 insertions(+), 38 deletions(-) delete mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 951eca2a13..0000000000 --- a/appveyor.yml +++ /dev/null @@ -1,33 +0,0 @@ -skip_tags: true -clone_depth: 50 - -os: Visual Studio 2017 - -environment: - matrix: - - PY_MAJOR_VER: 3 - PYTHON_ARCH: "x86" - - PY_MAJOR_VER: 3 - PYTHON_ARCH: "x86_64" - -platform: - - x64 - -build_script: - - cmd: SET MKL_NUM_THREADS=1 - - cmd: SET NUMEXPR_NUM_THREADS=1 - - cmd: SET OMP_NUM_THREADS=1 - - cmd: SET OPENBLAS_NUM_THREADS=1 - - ps: Start-FileDownload "https://repo.continuum.io/miniconda/Miniconda$env:PY_MAJOR_VER-latest-Windows-$env:PYTHON_ARCH.exe" C:\Miniconda.exe; echo "Finished downloading miniconda" - - cmd: C:\Miniconda.exe /S /D=C:\Py - - cmd: SET PATH=C:\Py;C:\Py\Scripts;C:\Py\Library\bin;%PATH% - - cmd: conda config --set always_yes yes - - cmd: conda update conda --quiet - - cmd: python -m pip install --upgrade pip - - cmd: conda install numpy cython pandas scipy patsy statsmodels matplotlib nbconvert nbformat pip pyyaml pyqt pyparsing --quiet - - cmd: conda install -c numba numba llvmlite - - cmd: pip install "pytest>=7,<7.1" pytest-xdist!=1.30 property_cached - - cmd: pip install -e . - -test_script: - - cmd: pytest -n 2 arch -m "(not slow)" --durations=25 diff --git a/arch/utility/array.py b/arch/utility/array.py index df6fc35a8a..23d9e6e108 100644 --- a/arch/utility/array.py +++ b/arch/utility/array.py @@ -38,7 +38,8 @@ def ensure1d( x: int | float | Sequence[int | float] | ArrayLike, name: Hashable | None, series: Literal[True] = ..., -) -> Series: ... # pragma: no cover +) -> Series: # pragma: no cover + ... # pragma: no cover @overload @@ -46,7 +47,8 @@ def ensure1d( x: int | float | Sequence[int | float] | ArrayLike, name: Hashable | None, series: Literal[False], -) -> np.ndarray: ... # pragma: no cover +) -> np.ndarray: # pragma: no cover + ... # pragma: no cover def ensure1d( diff --git a/arch/utility/timeseries.py b/arch/utility/timeseries.py index 477e32df89..23589170d0 100644 --- a/arch/utility/timeseries.py +++ b/arch/utility/timeseries.py @@ -48,7 +48,8 @@ def add_trend( prepend: bool = ..., nobs: int = ..., has_constant: Literal["raise", "add", "skip"] = ..., -) -> Float64Array: ... # pragma: no cover +) -> Float64Array: # pragma: no cover + ... # pragma: no cover @overload @@ -58,7 +59,8 @@ def add_trend( prepend: bool = ..., nobs: None = ..., has_constant: Literal["raise", "add", "skip"] = ..., -) -> Float64Array: ... # pragma: no cover +) -> Float64Array: # pragma: no cover + ... # pragma: no cover @overload @@ -68,7 +70,8 @@ def add_trend( prepend: bool = ..., nobs: None = ..., has_constant: Literal["raise", "add", "skip"] = ..., -) -> pd.DataFrame: ... # pragma: no cover +) -> pd.DataFrame: # pragma: no cover + ... # pragma: no cover def add_trend(