Skip to content

Commit 892d0da

Browse files
Martin EastwoodMartin Eastwood
authored andcommitted
updated unit tests
1 parent b0251f2 commit 892d0da

File tree

12 files changed

+99
-40
lines changed

12 files changed

+99
-40
lines changed

docs/changelog/index.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Version Numbering
77
`penaltyblog` follows the SemVer versioning guidelines. For more information,
88
see `semver.org <http://semver.org/>`_
99

10-
v0.9.0 (xxxx-xx-xx)
10+
v1.0.0 (xxxx-xx-xx)
1111
^^^^^^^^^^^^^^
1212
- Removed pymc as a dependency
1313
- Updated all other dependency versions
@@ -19,13 +19,15 @@ v0.9.0 (xxxx-xx-xx)
1919
- Removed obsolete sofifa and espn scrapers
2020
- Optimised RPS calculation
2121
- Optimised ELO code
22-
- Refactored Kelly Criterion code
22+
- Optimised Kelly Criterion code
2323
- Updated `FootballProbabilityGrid` to store its internal matrix as a numpy array
2424
- Updated all example notebooks
2525
- Increased unit test coverage
2626
- Added CI/CD
2727
- Removed Poetry from build step
2828
- Updated documentation
29+
- Added type hinting to `Colley` class
30+
- Added type hinting to `Massey` class
2931

3032
v0.8.1 (2023-09-31)
3133
^^^^^^^^^^^^^^

penaltyblog/models/bayesian_bivariate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(
6262
goals_away: Union[Sequence[int], NDArray],
6363
teams_home: Union[Sequence[int], NDArray],
6464
teams_away: Union[Sequence[int], NDArray],
65-
weights: Union[float, Sequence[float], NDArray],
65+
weights: Union[float, Sequence[float], NDArray] = 1.0,
6666
):
6767
"""
6868
Initializes the BayesianBivariateGoalModel instance with the provided match data.

penaltyblog/models/bayesian_hierarchical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(
7171
goals_away: Union[Sequence[int], NDArray],
7272
teams_home: Union[Sequence[int], NDArray],
7373
teams_away: Union[Sequence[int], NDArray],
74-
weights: Union[float, Sequence[float], NDArray],
74+
weights: Union[float, Sequence[float], NDArray] = 1.0,
7575
):
7676
self.fixtures = pd.DataFrame(
7777
{

penaltyblog/models/bayesian_random_intercept.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def __init__(
8181
goals_away: Union[Sequence[int], NDArray],
8282
teams_home: Union[Sequence[int], NDArray],
8383
teams_away: Union[Sequence[int], NDArray],
84-
weights: Union[float, Sequence[float], NDArray],
84+
weights: Union[float, Sequence[float], NDArray] = 1.0,
8585
):
8686
self.fixtures = pd.DataFrame(
8787
{
@@ -214,7 +214,7 @@ def fit(self, draws: int = 5000, warmup: int = 2000):
214214
tmp.flush()
215215
self.model = cmdstanpy.CmdStanModel(stan_file=tmp.name)
216216
self.fit_result = self.model.sample(
217-
data=data, iter_sampling=draws, warmup=2000
217+
data=data, iter_sampling=draws, iter_warmup=warmup
218218
)
219219

220220
self.fitted = True

penaltyblog/models/bayesian_skellam.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def __init__(
6060
goals_away: Union[Sequence[int], NDArray],
6161
teams_home: Union[Sequence[int], NDArray],
6262
teams_away: Union[Sequence[int], NDArray],
63-
weights: Union[float, Sequence[float], NDArray],
63+
weights: Union[float, Sequence[float], NDArray] = 1.0,
6464
):
6565
self.fixtures = pd.DataFrame(
6666
{

penaltyblog/models/football_probability_grid.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Callable, List
22

33
import numpy as np
4+
from numpy.typing import NDArray
45

56

67
class FootballProbabilityGrid:
@@ -10,7 +11,7 @@ class FootballProbabilityGrid:
1011

1112
def __init__(
1213
self,
13-
goal_matrix: List[List[float]],
14+
goal_matrix: NDArray,
1415
home_goal_expectation: float,
1516
away_goal_expectation: float,
1617
):

penaltyblog/ratings/colley.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
from typing import Sequence, Union
2+
13
import numpy as np
24
import pandas as pd
5+
from numpy.typing import NDArray
36

47

58
class Colley:
@@ -8,16 +11,16 @@ class Colley:
811
912
Parameters
1013
----------
11-
goals_home : list
14+
goals_home : array-like
1215
List of goals scored by the home teams
1316
14-
goals_away : list
17+
goals_away : array-like
1518
List of goals scored by the away teams
1619
17-
teams_home : list
20+
teams_home : array-like
1821
List of names of the home teams
1922
20-
teams_away : list
23+
teams_away : array-like
2124
List of names of the away teams
2225
2326
include_draws : bool
@@ -31,12 +34,12 @@ class Colley:
3134

3235
def __init__(
3336
self,
34-
goals_home,
35-
goals_away,
36-
teams_home,
37-
teams_away,
38-
include_draws=True,
39-
draw_weight=0.5,
37+
goals_home: Union[Sequence[int], NDArray],
38+
goals_away: Union[Sequence[int], NDArray],
39+
teams_home: Sequence[str],
40+
teams_away: Sequence[str],
41+
include_draws: bool = True,
42+
draw_weight: float = 0.5,
4043
):
4144
self.goals_home = goals_home
4245
self.goals_away = goals_away

penaltyblog/ratings/massey.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
from typing import Sequence, Union
2+
13
import numpy as np
24
import pandas as pd
5+
from numpy.typing import NDArray
36

47

58
class Massey:
@@ -8,25 +11,25 @@ class Massey:
811
912
Parameters
1013
----------
11-
goals_home : list
14+
goals_home : array-like
1215
List of goals scored by the home teams
1316
14-
goals_away : list
17+
goals_away : array-like
1518
List of goals scored by the away teams
1619
17-
teams_home : list
20+
teams_home : array-like
1821
List of names of the home teams
1922
20-
teams_away : list
23+
teams_away : array-like
2124
List of names of the away teams
2225
"""
2326

2427
def __init__(
2528
self,
26-
goals_home,
27-
goals_away,
28-
teams_home,
29-
teams_away,
29+
goals_home: Union[Sequence[int], NDArray],
30+
goals_away: Union[Sequence[int], NDArray],
31+
teams_home: Sequence[str],
32+
teams_away: Sequence[str],
3033
):
3134
self.goals_home = goals_home
3235
self.goals_away = goals_away

penaltyblog/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.9.0" # noqa
1+
__version__ = "1.0.0" # noqa

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "penaltyblog"
3-
version = "0.9.0"
3+
version = "1.0.0"
44
description = "Library from http://pena.lt/y/blog for scraping and modelling football (soccer) data"
55
authors = [{ name = "Martin Eastwood", email = "[email protected]" }]
66
readme = "README.md"

0 commit comments

Comments
 (0)