Skip to content

Commit 438adf5

Browse files
committed
CI: Add Python 3.13 to run
Reformat where needed Add additional CI jobs
1 parent 8ff5a5e commit 438adf5

File tree

8 files changed

+36
-31
lines changed

8 files changed

+36
-31
lines changed

arch/tests/univariate/test_distribution.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_studentst(self, seed):
5858
# Direct calculation of PDF, then log
5959
constant = np.exp(gammaln(0.5 * (v + 1)) - gammaln(0.5 * v))
6060
pdf = constant / np.sqrt(np.pi * (v - 2) * self.sigma2)
61-
pdf *= (1 + self.resids ** 2.0 / (self.sigma2 * (v - 2))) ** (-(v + 1) / 2)
61+
pdf *= (1 + self.resids**2.0 / (self.sigma2 * (v - 2))) ** (-(v + 1) / 2)
6262
ll2 = np.log(pdf).sum()
6363
assert_almost_equal(ll1, ll2)
6464

@@ -87,14 +87,14 @@ def test_skewstudent(self, seed):
8787
# Direct calculation of PDF, then log
8888
const_c = gamma((eta + 1) / 2) / ((np.pi * (eta - 2)) ** 0.5 * gamma(eta / 2))
8989
const_a = 4 * lam * const_c * (eta - 2) / (eta - 1)
90-
const_b = (1 + 3 * lam ** 2 - const_a ** 2) ** 0.5
90+
const_b = (1 + 3 * lam**2 - const_a**2) ** 0.5
9191

92-
resids = self.resids / self.sigma2 ** 0.5
92+
resids = self.resids / self.sigma2**0.5
9393
power = -(eta + 1) / 2
9494
pdf = (
9595
const_b
9696
* const_c
97-
/ self.sigma2 ** 0.5
97+
/ self.sigma2**0.5
9898
* (
9999
1
100100
+ 1

arch/tests/univariate/test_mean.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ def test_param_cov():
13541354
def test_plot_bad_index():
13551355
import matplotlib.pyplot as plt
13561356

1357-
idx = sorted(f"{a}{b}{c}" for a, b, c, in product(*([ascii_lowercase] * 3)))
1357+
idx = sorted(f"{a}{b}{c}" for a, b, c in product(*([ascii_lowercase] * 3)))
13581358
sp500_copy = SP500.copy()
13591359
sp500_copy.index = idx[: sp500_copy.shape[0]]
13601360
res = ConstantMean(sp500_copy).fit(disp=False)

arch/unitroot/critical_values/simulation/dfgls_critical_values_simulation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def dfgsl_simulation(
136136
results = np.zeros((len(percentiles), len(T), EX_NUM))
137137

138138
for i in range(EX_NUM):
139-
print(f"Experiment Number {i + 1} of {EX_NUM} " "(trend {tr})")
139+
print(f"Experiment Number {i + 1} of {EX_NUM} (trend {tr})")
140140
now = datetime.datetime.now()
141141
parallel, p_func, n_jobs = parallel_func(
142142
wrapper, n_jobs=NUM_JOBS, verbose=2

arch/unitroot/unitroot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120

121121

122122
def _is_reduced_rank(
123-
x: Union[Float64Array, DataFrame]
123+
x: Union[Float64Array, DataFrame],
124124
) -> tuple[bool, Union[int, None]]:
125125
"""
126126
Check if a matrix has reduced rank preferring quick checks

arch/univariate/distribution.py

+22-21
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Distributions to use in ARCH models. All distributions must inherit from
33
:class:`Distribution` and provide the same methods with the same inputs.
44
"""
5+
56
from abc import ABCMeta, abstractmethod
67
from collections.abc import Sequence
78
from typing import Callable, Optional, Union
@@ -100,8 +101,8 @@ def _check_constraints(
100101
for p, n, b in zip(params, self.name, bounds):
101102
if not (b[0] <= p <= b[1]):
102103
raise ValueError(
103-
"{} does not satisfy the bounds requirement "
104-
"of ({}, {})".format(n, *b)
104+
f"{n} does not satisfy the bounds requirement of "
105+
f"({b[0]}, {b[1]})"
105106
)
106107
return asarray(params)
107108

@@ -205,7 +206,7 @@ def loglikelihood(
205206
resids: ArrayLike,
206207
sigma2: ArrayLike,
207208
individual: bool = False,
208-
) -> Union[float , Float64Array]:
209+
) -> Union[float, Float64Array]:
209210
"""
210211
Loglikelihood evaluation.
211212
@@ -264,7 +265,7 @@ def ppf(
264265
self,
265266
pits: Union[float, Sequence[float], ArrayLike1D],
266267
parameters: Union[Sequence[float], ArrayLike1D, None] = None,
267-
) -> Union[float , Float64Array]:
268+
) -> Union[float, Float64Array]:
268269
"""
269270
Inverse cumulative density function (ICDF)
270271
@@ -414,7 +415,7 @@ def loglikelihood(
414415
resids: ArrayLike,
415416
sigma2: ArrayLike,
416417
individual: bool = False,
417-
) -> Union[float , Float64Array]:
418+
) -> Union[float, Float64Array]:
418419
r"""Computes the log-likelihood of assuming residuals are normally
419420
distributed, conditional on the variance
420421
@@ -446,7 +447,7 @@ def loglikelihood(
446447
+\frac{x^{2}}{\sigma^{2}}\right)
447448
448449
"""
449-
lls = -0.5 * (log(2 * pi) + log(sigma2) + resids ** 2.0 / sigma2)
450+
lls = -0.5 * (log(2 * pi) + log(sigma2) + resids**2.0 / sigma2)
450451
if individual:
451452
return lls
452453
else:
@@ -557,7 +558,7 @@ def loglikelihood(
557558
resids: ArrayLike,
558559
sigma2: ArrayLike,
559560
individual: bool = False,
560-
) -> Union[float , Float64Array]:
561+
) -> Union[float, Float64Array]:
561562
r"""Computes the log-likelihood of assuming residuals are have a
562563
standardized (to have unit variance) Student's t distribution,
563564
conditional on the variance.
@@ -595,7 +596,7 @@ def loglikelihood(
595596
nu = parameters[0]
596597
lls = gammaln((nu + 1) / 2) - gammaln(nu / 2) - log(pi * (nu - 2)) / 2
597598
lls -= 0.5 * (log(sigma2))
598-
lls -= ((nu + 1) / 2) * (log(1 + (resids ** 2.0) / (sigma2 * (nu - 2))))
599+
lls -= ((nu + 1) / 2) * (log(1 + (resids**2.0) / (sigma2 * (nu - 2))))
599600

600601
if individual:
601602
return lls
@@ -685,7 +686,7 @@ def partial_moment(
685686
nu = parameters[0]
686687
var = nu / (nu - 2)
687688
scale = 1.0 / sqrt(var)
688-
moment = (scale ** n) * self._ord_t_partial_moment(n, z / scale, nu)
689+
moment = (scale**n) * self._ord_t_partial_moment(n, z / scale, nu)
689690
return moment
690691

691692
@staticmethod
@@ -729,9 +730,9 @@ def _ord_t_partial_moment(n: int, z: float, nu: float) -> float:
729730
elif n == 1:
730731
c = gamma(0.5 * (nu + 1)) / (sqrt(nu * pi) * gamma(0.5 * nu))
731732
e = 0.5 * (nu + 1)
732-
moment = (0.5 * (c * nu) / (1 - e)) * ((1 + (z ** 2) / nu) ** (1 - e))
733+
moment = (0.5 * (c * nu) / (1 - e)) * ((1 + (z**2) / nu) ** (1 - e))
733734
else:
734-
t1 = (z ** (n - 1)) * (nu + z ** 2) * stats.t.pdf(z, nu)
735+
t1 = (z ** (n - 1)) * (nu + z**2) * stats.t.pdf(z, nu)
735736
t2 = (n - 1) * nu * StudentsT._ord_t_partial_moment(n - 2, z, nu)
736737
moment = (1 / (n - nu)) * (t1 - t2)
737738
return moment
@@ -846,7 +847,7 @@ def loglikelihood(
846847
const_a = self.__const_a(parameters)
847848
const_b = self.__const_b(parameters)
848849

849-
resids = resids / sigma2 ** 0.5
850+
resids = resids / sigma2**0.5
850851
lls = log(const_b) + const_c - log(sigma2) / 2
851852
if abs(lam) >= 1.0:
852853
lam = sign(lam) * (1.0 - 1e-6)
@@ -911,7 +912,7 @@ def simulate(
911912
def parameter_names(self) -> list[str]:
912913
return ["eta", "lambda"]
913914

914-
def __const_a(self, parameters: Union[Float64Array , Sequence[float]]) -> float:
915+
def __const_a(self, parameters: Union[Float64Array, Sequence[float]]) -> float:
915916
"""
916917
Compute a constant.
917918
@@ -930,7 +931,7 @@ def __const_a(self, parameters: Union[Float64Array , Sequence[float]]) -> float:
930931
c = self.__const_c(parameters)
931932
return float(4 * lam * exp(c) * (eta - 2) / (eta - 1))
932933

933-
def __const_b(self, parameters: Union[Float64Array , Sequence[float]]) -> float:
934+
def __const_b(self, parameters: Union[Float64Array, Sequence[float]]) -> float:
934935
"""
935936
Compute b constant.
936937
@@ -946,7 +947,7 @@ def __const_b(self, parameters: Union[Float64Array , Sequence[float]]) -> float:
946947
"""
947948
lam = float(parameters[1])
948949
a = self.__const_a(parameters)
949-
return (1 + 3 * lam ** 2 - a ** 2) ** 0.5
950+
return (1 + 3 * lam**2 - a**2) ** 0.5
950951

951952
@staticmethod
952953
def __const_c(parameters: Union[Float64Array, Sequence[float]]) -> float:
@@ -999,7 +1000,7 @@ def ppf(
9991000
self,
10001001
pits: Union[float, Sequence[float], ArrayLike1D],
10011002
parameters: Union[Sequence[float], ArrayLike1D, None] = None,
1002-
) -> Union[float , Float64Array]:
1003+
) -> Union[float, Float64Array]:
10031004
parameters = self._check_constraints(parameters)
10041005
scalar = isscalar(pits)
10051006
if scalar:
@@ -1052,8 +1053,8 @@ def moment(
10521053
)
10531054
l_pmom = ((-1) ** k) * r_pmom
10541055

1055-
lhs = (1 - lam) * (lscale ** k) * (loc ** (n - k)) * l_pmom
1056-
rhs = (1 + lam) * (rscale ** k) * (loc ** (n - k)) * r_pmom
1056+
lhs = (1 - lam) * (lscale**k) * (loc ** (n - k)) * l_pmom
1057+
rhs = (1 + lam) * (rscale**k) * (loc ** (n - k)) * r_pmom
10571058
moment += comb(n, k) * (lhs + rhs)
10581059

10591060
return moment
@@ -1083,15 +1084,15 @@ def partial_moment(
10831084
lhs = (
10841085
(1 - lam)
10851086
* (loc ** (n - k))
1086-
* (lscale ** k)
1087+
* (lscale**k)
10871088
* StudentsT._ord_t_partial_moment(k, z=(lbound - loc) / lscale, nu=eta)
10881089
)
10891090

10901091
if z > loc:
10911092
rhs = (
10921093
(1 + lam)
10931094
* (loc ** (n - k))
1094-
* (rscale ** k)
1095+
* (rscale**k)
10951096
* (
10961097
StudentsT._ord_t_partial_moment(k, z=(z - loc) / rscale, nu=eta)
10971098
- StudentsT._ord_t_partial_moment(k, z=0.0, nu=eta)
@@ -1285,7 +1286,7 @@ def partial_moment(
12851286
parameters = self._check_constraints(parameters)
12861287
nu = parameters[0]
12871288
scale = 1.0 / sqrt(stats.gennorm(nu).var())
1288-
moment = (scale ** n) * self._ord_gennorm_partial_moment(n, z / scale, nu)
1289+
moment = (scale**n) * self._ord_gennorm_partial_moment(n, z / scale, nu)
12891290
return moment
12901291

12911292
@staticmethod

ci/azure/azure_template_posix.yml

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
vmImage: ${{ parameters.vmImage }}
1717
strategy:
1818
matrix:
19+
python_313:
20+
python.version: '3.13'
1921
python_312:
2022
python.version: '3.12'
2123
python_311:

ci/azure/azure_template_windows.yml

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
python.version: '3.11'
2727
python312_win_latest:
2828
python.version: '3.12'
29+
python313_win_latest:
30+
python.version: '3.12'
2931
maxParallel: 10
3032

3133
steps:

requirements-dev.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ pytest-xdist
1616
pytest-cov
1717

1818
# formatting
19-
black[jupyter]~=24.8.0
20-
isort~=5.0
19+
black[jupyter]~=24.10.0
20+
isort~=5.12
2121
colorama
2222
flake8
2323
mypy
24-
ruff
24+
ruff>=0.8.6
2525
pyupgrade>=3.4.0
2626
jupyterlab-code-formatter
2727

0 commit comments

Comments
 (0)