Skip to content

Add support for Python 3.10-12 #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
os: [Ubuntu, macOS, Windows]
python-version: [3.8, 3.9]
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py36-plus]
args: [--py39-plus]

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Existing time series analysis libraries include [statsmodels](https://www.statsm

### Installation Requirements

TorchTS supports Python 3.8+ and has the following dependencies:
TorchTS supports Python 3.9+ and has the following dependencies:

- [PyTorch](https://pytorch.org/)
- [PyTorch Lightning](https://pytorchlightning.ai/)
Expand Down
2,374 changes: 1,225 additions & 1,149 deletions poetry.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ classifiers = [
]

[tool.poetry.dependencies]
python = ">=3.8,<3.10"
torch = "^1.4"
pytorch-lightning = "^1.2"
scipy = "^1.7.1"
python = ">=3.9,<3.13"
torch = "^2.2.2"
pytorch-lightning = "^2.2.3"
scipy = "^1.13.0"

[tool.poetry.group.test.dependencies]
pytest = "^7.0.1"
pytest-cov = "^3.0.0"
pytest-mock = "^3.7.0"
pre-commit = "^2.17.0"
pytest = "^8.2.0"
pytest-cov = "^5.0.0"
pytest-mock = "^3.14.0"
pre-commit = "^3.7.0"

[tool.poetry.group.docs.dependencies]
sphinx = "^4.4.0"
sphinx = "^7.3.7"
asteroid-sphinx-theme = "^0.0.3"

[build-system]
Expand Down
3 changes: 2 additions & 1 deletion tests/nn/test_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_step_backward(euler_model):
model, _ = euler_model
loss = model._step(batch, 0, 0)
assert (loss.item() - (1.2 - 1.1) ** 2) < 1e-6
model.backward(loss, None, 0)
model.backward(loss)
model.optimizer(model.parameters()).step()
coeffs = model.get_coeffs()
assert coeffs["alpha"] < 2
Expand All @@ -99,6 +99,7 @@ def test_step_backward(euler_model):
def test_fit(euler_model):
"""Test the step and backward function"""
torch.manual_seed(0)
torch.set_default_device("cpu")
model, _ = euler_model
model.fit(torch.Tensor([[1.0]]), torch.Tensor([[1.1]]), max_epochs=1, batch_size=1)
coeffs = model.get_coeffs()
Expand Down
1 change: 1 addition & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def test_step(mocker):

def test_train():
torch.manual_seed(0)
torch.set_default_device("cpu")

slope_init = 2
intercept_init = -1
Expand Down
2 changes: 1 addition & 1 deletion torchts/nn/models/ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,6 @@ def _step(self, batch, batch_idx, num_batches):
loss = self.criterion(predictions, y)
return loss

def backward(self, loss, optimizer, optimizer_idx):
def backward(self, loss):
# use retain_graph=True to mitigate RuntimeError
loss.backward(retain_graph=True)
Loading