Skip to content

Commit fed7f6d

Browse files
sluo1250Copilot
andauthored
Add support for Python 3.13 (#894)
- Bump requires-python from >=3.9 to >=3.12 (arviz requires >=3.12) - Update classifiers to 3.12/3.13 - Bump dependency minimums for 3.13 wheel availability - Replace np.in1d with np.isin (removed in NumPy 2.x) - Fix deprecated pandas freq aliases (M -> ME) - Fix chained assignment for pandas Copy-on-Write - Fix invalid escape sequence in docstring - Update CI actions to v4/v5 and test matrix to [3.12, 3.13] - Update tox envlist to py312, py313 Closes #891 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9dff6d1 commit fed7f6d

10 files changed

Lines changed: 31 additions & 32 deletions

File tree

.github/workflows/pypi-deploy.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ jobs:
88
deploy:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v4
1212
- name: Set up Python
13-
uses: actions/setup-python@v2
13+
uses: actions/setup-python@v5
1414
with:
1515
python-version: "3.x"
1616
- name: Install dependencies

.github/workflows/test.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
lint:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v3
9+
- uses: actions/checkout@v4
1010
- uses: psf/black@stable
1111
with:
1212
options: "--check --verbose --color"
@@ -20,11 +20,11 @@ jobs:
2020
# You can use PyPy versions in python-version.
2121
# For example, pypy2 and pypy3
2222
matrix:
23-
python-version: [3.9]
23+
python-version: ["3.12", "3.13"]
2424
steps:
25-
- uses: actions/checkout@v2
25+
- uses: actions/checkout@v4
2626
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v2
27+
uses: actions/setup-python@v5
2828
with:
2929
python-version: ${{ matrix.python-version }}
3030
# You can test your matrix by printing the current Python version

orbit/diagnostics/metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def rmsse(test_actual, test_prediction, train_actual):
6060
compared to a naive lag-1 predictor.
6161
6262
.. math::
63-
\sqrt{\frac{1}{h}\frac{\sum^{n+h}_{t=n+1}(Y_t-\hat{Y}_t)^2}{\frac{1}{n-1}\sum^{n}_{t=2}{(Y_t-Y_{t-1})^2}
63+
\\sqrt{\\frac{1}{h}\\frac{\\sum^{n+h}_{t=n+1}(Y_t-\\hat{Y}_t)^2}{\\frac{1}{n-1}\\sum^{n}_{t=2}{(Y_t-Y_{t-1})^2}
6464
6565
Notes
6666
-----

orbit/template/ktr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ def _generate_insample_tp(self, training_meta, date_array):
760760
"""Used in _generate_seas"""
761761
train_date_array = training_meta[TrainingMetaKeys.DATE_ARRAY.value]
762762
num_of_observations = training_meta[TrainingMetaKeys.NUM_OF_OBS.value]
763-
idx = np.nonzero(np.in1d(train_date_array, date_array))[0]
763+
idx = np.nonzero(np.isin(train_date_array, date_array))[0]
764764
tp = (idx + 1) / num_of_observations
765765
return tp
766766

pyproject.toml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.black]
22
line-length = 88
3-
target-version = ['py39', 'py310', 'py311']
3+
target-version = ['py312', 'py313']
44
include = '\.pyi?$'
55
extend-exclude = '''
66
# A regex preceded with ^/ will apply only to files and directories
@@ -31,27 +31,26 @@ maintainers = [
3131
version = "1.1.5.0"
3232
description = "Orbit is a package for Bayesian time series modeling and inference."
3333
readme = "README.md"
34-
requires-python = ">=3.9"
34+
requires-python = ">=3.12"
3535
dependencies = [
3636
"arviz",
3737
"cmdstanpy>=1.2.1",
3838
"importlib_resources",
39-
"matplotlib>=3.3.2",
40-
"numpy>=1.18",
41-
"pandas>=1.0.3",
39+
"matplotlib>=3.9.2",
40+
"numpy>=2.1.0",
41+
"pandas>=2.2.3",
4242
"pyro-ppl>=1.4.0",
43-
"scipy>=1.4.1",
44-
"seaborn>=0.10.0",
45-
"statsmodels>=0.11.1",
46-
"torch>=1.11.0",
43+
"scipy>=1.14.1",
44+
"seaborn>=0.13.2",
45+
"statsmodels>=0.14.3",
46+
"torch>=2.5.0",
4747
"tqdm>=4.36.1",
4848
]
4949
license = {text = "Apache License 2.0"}
5050
classifiers = [
5151
"Programming Language :: Python",
52-
"Programming Language :: Python :: 3.9",
53-
"Programming Language :: Python :: 3.10",
54-
"Programming Language :: Python :: 3.11",
52+
"Programming Language :: Python :: 3.12",
53+
"Programming Language :: Python :: 3.13",
5554
]
5655
[project.optional-dependencies]
5756
dev = [

requirements.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ arviz
22
cmdstanpy>=1.2.1
33
importlib_resources
44
ipywidgets
5-
matplotlib>=3.3.2
6-
numpy>=1.26.4
7-
pandas>=2.3.0
5+
matplotlib>=3.9.2
6+
numpy>=2.1.0
7+
pandas>=2.2.3
88
pyro-ppl>=1.4.0
9-
scipy>=1.4.1
10-
seaborn>=0.10.0
9+
scipy>=1.14.1
10+
seaborn>=0.13.2
1111
setuptools>=42
12-
statsmodels>=0.14.4
12+
statsmodels>=0.14.3
1313
torch
1414
tqdm>=4.36.1

tests/orbit/models/test_dlt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def test_invalid_regressor(make_weekly_data, regressor_signs, invalid_input):
156156
train_df, test_df, coef = make_weekly_data
157157
regressor_col = train_df.columns.tolist()[2:]
158158
# make invalid values
159-
train_df[regressor_col[0]][36] = invalid_input
159+
train_df.loc[train_df.index[36], regressor_col[0]] = invalid_input
160160
expected_flag = False
161161
try:
162162
dlt = DLT(
@@ -186,7 +186,7 @@ def test_invalid_predict_regressor(make_weekly_data, invalid_input):
186186
train_df, test_df, coef = make_weekly_data
187187
regressor_col = train_df.columns.tolist()[2:]
188188
# make invalid values
189-
test_df[regressor_col[0]][3] = invalid_input
189+
test_df.loc[test_df.index[3], regressor_col[0]] = invalid_input
190190
expected_flag = False
191191
try:
192192
dlt = DLT(

tests/orbit/models/test_ktr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def test_ktr_regression(make_daily_data, regressor_col):
131131

132132
@pytest.mark.parametrize(
133133
"regression_knot_dates",
134-
[pd.date_range(start="2016-03-01", end="2019-01-01", freq="3M")],
134+
[pd.date_range(start="2016-03-01", end="2019-01-01", freq="3ME")],
135135
)
136136
@pytest.mark.parametrize(
137137
"make_daily_data", [{"seasonality": "dual", "with_coef": True}], indirect=True

tests/orbit/models/test_ktrlite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def test_ktrlite_level_segments(make_daily_data, level_segments):
107107
@pytest.mark.parametrize(
108108
"level_knot_dates",
109109
[
110-
pd.date_range(start="2016-03-01", end="2019-01-01", freq="3M"),
111-
pd.date_range(start="2016-03-01", end="2019-01-01", freq="6M"),
110+
pd.date_range(start="2016-03-01", end="2019-01-01", freq="3ME"),
111+
pd.date_range(start="2016-03-01", end="2019-01-01", freq="6ME"),
112112
],
113113
)
114114
@pytest.mark.parametrize(

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py38
2+
envlist = py312, py313
33

44
[testenv]
55
deps = pytest

0 commit comments

Comments
 (0)