Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
MAINT: Improve coverage
Update setuptools requirements
Remove distutils
  • Loading branch information
Kevin Sheppard authored and bashtage committed Jul 13, 2022
1 parent 8002002 commit 0198ad6
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Expand Up @@ -28,6 +28,9 @@ exclude_lines =
elif TYPE_CHECKING
# Cython function declarations
cdef
# Cython functions with void
cdef void


include = */arch/*
omit =
Expand Down
2 changes: 1 addition & 1 deletion arch/bootstrap/_samplers.pyx
@@ -1,5 +1,5 @@
#!python
#cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
#cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True, binding=True

import numpy as np

Expand Down
14 changes: 14 additions & 0 deletions arch/tests/univariate/test_arch_in_mean.py
Expand Up @@ -123,6 +123,20 @@ def test_supported(good_vol):
assert res2.params.shape == (n,)


def test_egarch_bad_params():
aim = ARCHInMean(SP500, volatility=EGARCH(), form="log")
res = aim.fit(disp=False)
sv = res.params.copy()
sv["omega"] = 4
sv["alpha[1]"] = 0.75
sv["beta[1]"] = 0.999998
res2 = aim.fit(disp=False, starting_values=sv)
n = res2.params.shape[0]
assert res.param_cov.shape == (n, n)
res3 = aim.fit(disp=False, starting_values=res.params)
assert res3.params.shape == (n,)


@pytest.mark.parametrize("form", ["log", "vol", 1.5])
def test_simulate_arx(form):
normal = Normal(seed=np.random.RandomState(0))
Expand Down
4 changes: 2 additions & 2 deletions arch/tests/univariate/test_mean.py
@@ -1,4 +1,3 @@
from distutils.version import LooseVersion
from io import StringIO
from itertools import product
from string import ascii_lowercase
Expand All @@ -15,6 +14,7 @@
assert_array_almost_equal,
assert_equal,
)
from packaging.version import parse
import pandas as pd
from pandas.testing import assert_frame_equal, assert_series_equal
import pytest
Expand Down Expand Up @@ -71,7 +71,7 @@

RTOL = 1e-4 if struct.calcsize("P") < 8 else 1e-6
DISPLAY: Literal["off"] = "off"
SP_LT_14 = LooseVersion(scipy.__version__) < LooseVersion("1.4")
SP_LT_14 = parse(scipy.__version__) < parse("1.4")
SP500 = 100 * sp500.load()["Adj Close"].pct_change().dropna()


Expand Down
27 changes: 8 additions & 19 deletions arch/typing.py
@@ -1,14 +1,14 @@
from __future__ import annotations

import datetime as dt
import sys
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Hashable,
List,
Literal,
Optional,
Tuple,
TypeVar,
Expand All @@ -20,17 +20,6 @@

NP_GTE_121 = np.lib.NumpyVersion(np.__version__) >= np.lib.NumpyVersion("1.21.0")

if sys.version_info >= (3, 8):
from typing import Literal
elif TYPE_CHECKING:
from typing_extensions import Literal
else:

class _Literal:
def __getitem__(self, item):
pass

Literal = _Literal()

__all__ = [
"NDArray",
Expand Down Expand Up @@ -59,13 +48,13 @@ def __getitem__(self, item):

NDArray = Union[np.ndarray]
if NP_GTE_121 and TYPE_CHECKING:
Float64Array = np.ndarray[Any, np.dtype[np.float64]]
Int64Array = np.ndarray[Any, np.dtype[np.int64]]
Int32Array = np.ndarray[Any, np.dtype[np.int32]]
IntArray = np.ndarray[Any, np.dtype[np.int_]]
BoolArray = np.ndarray[Any, np.dtype[np.bool_]]
AnyArray = np.ndarray[Any, Any]
Uint32Array = np.ndarray[Any, np.dtype[np.uint32]]
Float64Array = np.ndarray[Any, np.dtype[np.float64]] # pragma: no cover
Int64Array = np.ndarray[Any, np.dtype[np.int64]] # pragma: no cover
Int32Array = np.ndarray[Any, np.dtype[np.int32]] # pragma: no cover
IntArray = np.ndarray[Any, np.dtype[np.int_]] # pragma: no cover
BoolArray = np.ndarray[Any, np.dtype[np.bool_]] # pragma: no cover
AnyArray = np.ndarray[Any, Any] # pragma: no cover
Uint32Array = np.ndarray[Any, np.dtype[np.uint32]] # pragma: no cover
else:
Uint32Array = (
IntArray
Expand Down
2 changes: 1 addition & 1 deletion arch/univariate/recursions.pyx
@@ -1,5 +1,5 @@
#!python
#cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
#cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True, binding=True

import numpy as np

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
@@ -1,8 +1,8 @@
[build-system]
requires = [
"setuptools>=45",
"setuptools>=61",
"wheel",
"setuptools_scm[toml]>=6.2",
"setuptools_scm[toml]>=7,<8",
"oldest-supported-numpy",
"numpy; python_version>='3.11'",
"Cython>=0.29.24"
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
@@ -1,5 +1,6 @@
# versioning
setuptools_scm>=6.4.2,<7.0.0
packaging

# Performance
cython>=0.29.30
Expand Down
7 changes: 4 additions & 3 deletions setup.py
@@ -1,8 +1,9 @@
from setuptools import Command, Extension, find_packages, setup
from setuptools.dist import Distribution
from setuptools.errors import CCompilerError, ExecError, PlatformError

from collections import defaultdict
from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError

import fnmatch
import os
import pathlib
Expand Down Expand Up @@ -201,8 +202,8 @@ def run_setup(binary: bool = True) -> None:
run_setup(binary=build_binary)
except (
CCompilerError,
DistutilsExecError,
DistutilsPlatformError,
ExecError,
PlatformError,
OSError,
ValueError,
):
Expand Down

0 comments on commit 0198ad6

Please sign in to comment.